1

I'm trying to integrate a 3rd party C++ DLL with a C# application. The 3rd party documentation says:

"The application must have a Windows Message loop in order to the use the API. It is through the message loop that the TCP messages are sent..."

My entry into the C# application is through a plugin framework, so it significantly more complicated that your average WinForms app however, I'm not sure I understand the mapping between MFC message loops and the loops issued by Threading.Dispatcher as recommended here and here

If C# obfuscates this completely, I suppose I could run a message loop in my CLI layer and poll for messages from the C# plugin.

I'm not even positive this is the issue; however my CLI layer works in a simple WinForms test application, but does not seem to catch callbacks with in the plugin ecosystem.

Thanks S.O Community!

UPDATE: Hmm, after looking more closely into the two links included above. I'm not actually confident they are germane.

Adding

Application.Run();

to my thread running the CLI layer does indeed pump the callbacks. But then it crashes, or throws an Access Violation (that my generic catch( Exception) never catches..). Frustratingly, this is the same error I get but the comments just acknowledge that this happens.

I don't have access to the form to get a handle or an application context. Most of answers I've found are for COM interfaces which this is not(i did try adding the STAThread attribute anyway, but to no avail.

Is there another call that will pump the Windows message loop once so I can put it in my own loop?

Community
  • 1
  • 1
David
  • 437
  • 4
  • 12
  • 2
    That's pretty vague. [Try this](http://stackoverflow.com/a/21684059/17034). – Hans Passant Jun 02 '15 at 14:53
  • @HansPassant I've tried to make it less vague, but I'm very confused. all of the Application methods, DoEvents, Run(), Run(ApplicationContext) all seem to pump all of the 3rd party callback during initialization, but then I get an exception (see link in update) – David Jun 03 '15 at 19:06
  • The point of pumping is to allow code to run in that 3rd party component. That this code then bombs with an AVE is par for the course, it does because it can. You cannot get help with bugs like that at this site, you'll need to use a telephone. – Hans Passant Jun 03 '15 at 21:35

0 Answers0