views:

126

answers:

2

Hi All,

I have a C# exe and some vc++ dll's . I am creating a callBackFunction in C# whichh takes structure as its Parameters. My c++ dll will fill this structure and return it back.But 95% of the time My Exe crashes. My dll is multi threaded and my C# has backgroundWorker in it. I have put try catch block to check if any exceptions are coming or not but no exception is being caught. Can any one suggest a better way to send data from my vc++ dll to c# exe

A: 

If you want you could implement a COM Interface, and then you could call the methods from that interface from any .Net client.

Basic example of implementation.

Adrian Faciu
+1  A: 

this must work:
(c#)

namespace Test
{
    public class CallbackClass
    {
        public void Callback(string s)
        {
            MessageBox.Show(s);
        }
    }
}  

(c++/cli)

...
Test::CallbackClass::Callback(gcnew System::String("woof!");
...
Vlad