Does COM interop respect .NET AppDomain boundaries for assembly loading?

拈花ヽ惹草 提交于 2019-12-03 07:03:11

Unfortunately, A COM component is loaded within Process Space and not within the context of an AppDomain. Thus, you will need to manually tear-down (Release and Unload) your Native DLLs (applies to both COM and P/Invoke). Simply destroying an appdomain will do you no good, but respawning the whole process shouldn't be necessary to reset COM state (simply recreating the COM object(s) should also normally work, this sounds like a bug within the component providers code, perhaps they can address it?)

References

(TechNet) Process Address Space

(MSDN) Application Domains

(MSDN) Boundaries: Processes and AppDomains

Here's the proof that Shaun Wilson's answer is correct

Don't make your Controller MBR. Create a small proxy, which loads the Controller in the second domain and starts it. That way Controller dll will not be loaded in the first domain.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!