I am having problems with my COM component written in .NET, throwing warnings that look like this:
Context 0x15eec0 is disabled. no proxy will be used to service the request for the COM component. This may result in data corruption or loss. To avoid this problem, please make sure that all contexts / apartments remain alive until the application is completely done using RuntimeCallableWrappers that represent the COM components that live inside them.
It seems to be caused by my calling GUI thread functions in a COM thread without the necessary synchronization. For reference, I use the guidelines set in http://msdn.microsoft.com/en-us/library/ms229609%28VS.80%29.aspx to create my GUI stream in a COM component.
My code looks something like this:
class COMClass {
public void Init() {
ComObject comObject = new ComObject();
Thread newThread = new Thread(new ThreadStart(delegate() {
Application.Run(new GUIForm(comObject));
}));
}
public void SomeMethod(){
comObject.DoSomething();
}
}
class GUIForm : Form {
ComObject com;
public GUIForm(ComObject com) {comObject = com;}
public void SomeButtonHandler(object sender, EventArgs e) {
comObject.SomeMethod();
}
}
Is there an established method to deal with this? Calls in the GUI are not a problem (Invoke / BeginInvoke), but calling another way seems more complicated ...
edit: This is also not an option to modify a COM object.
source
share