COM - .NET Interop - Winform from COM client -
I have a WinForm-containing .NET application. This WinForm includes an unmanaged ActiveX control and some other controls. This app works fine in standalone mode Now we want to publish some kind of interface, so this winform can be used to interop functionality from unmanaged C ++ / MFC applications. Client applications will show this form in a model manner. When the user gives details of the input, the client is given the same by using the Com Event Source / Sync (or Connection Point) method.
I have followed many articles and a method working for us
But if I start more than one thread from the same client application, then the second example of the form is reached The violation throws an exception because the ActiveX control on the form always expects the thread to base my thread (based on).
Can you please tell me what is the correct way of displaying a WinForm functionality for unmanaged client applications through the interop?
Many thanks
You get all the necessary information from the linked article Organize a form in an unmanaged app systematically You should search the source of AV somewhere else Get started using the debugger You can force the debug + exception dialog to stop the exception with the checkbox.
The STA requirement is almost always enough to keep the activation control properly in a multi-threaded application. It guarantees that all method calls are made on exact thread in which the cocalo was made. In other words, any instance variable is guaranteed to be used in a thread-safe way inside the coal-slave implementation.
There is a guarantee that you do not have it here, though this is whether the control handles the global situation properly or not. The instance variables are secure, are not global variables, when you use controls in different threads. A possible solution for this is to use only one thread instead of an STA thread for each form instance. It is a bit tricky, you will need an invisible assistant form which manages the thread. Keeping it alive and making examples of new forms through its inkjog () method.
Before you go there, find out what is crashing first.
Comments
Post a Comment