Oct 18, 2011 at 3:37 AM
Edited Oct 18, 2011 at 3:47 AM
Yes, this is normal, this error is a result of using the Microsoft UPnP COMObjects under an Multi Threaded apartment environment, its due to the COM implementation not fully supporting MTA applications, it will not cause any problems and will not error unless
debugging in the IDE, you can disable the warning from showing while debugging by disabling the respective Debugging Assistant MDA notification with in Visual Studio by doing the following:
1) In the menus select Debug - Exceptions
2) Open up the Managed Debug Assistants and uncheck the thrown tickbbox for the items called "ContextSwitchDeadlock" and "DisconnectedContext" MDAs
This should in no way affect your compiled program, and unfortunately, without writing our own UPnP Implementation from scratch - which I have started to work on - (ie. not using the Microsoft UPnP COM objects) there isnt a lot we can do about it.
More information on these MDAs can be found on the microsoft site:
The context switch deadlock should not cause any memory leaks in this instance as it isnt happening when the UPnP objects are being freed.
There are ways around it however, they are very messy, for example do not use any Device / Service COM objects returned by an asynchronous process, instead only use synchronous discovery, but like I said its messy! As you can see they have done it here in
the sonority open source code:
In the second constructor they to see if the current thread is STA and if it is it recreates the device using synchronous methods instead of using the asynchronous device, but personally I dont see the point, as it seems to work fine without doing that anyway.