[英]Load my C# class library in its own app domain and unload when exception occurs without disturbing third party application
I am createing plugins using c# class library, which can be loaded into third party application, but i want it to be loaded in its own app domain and unload when exception occurs in my code without affecting third party application process 我正在使用c#类库创建插件,该类库可以加载到第三方应用程序中,但是我希望将其加载到自己的应用程序域中,并在代码中发生异常时卸载,而不会影响第三方应用程序的过程
Here is the scenario, we have a third party application which allows to load plugins. 在这种情况下,我们有一个允许加载插件的第三方应用程序。 I am creating plugins, which can be loaded into this third party application.
我正在创建插件,可以将其加载到此第三方应用程序中。 but when it loads, by default it loads in its own app domain, but i want my plugin to be loaded in its own app domain with out affecting the third party process when an exception occurs in my plugin..Can you help me with the code to achieve the above requirement?
但是在加载时,默认情况下会在其自己的应用程序域中加载,但是我希望我的插件在其自己的应用程序域中加载,而不会在插件发生异常时影响第三方进程。代码达到以上要求?
The host application is what chooses the app domain to load the plugin. 主机应用程序是选择应用程序域来加载插件的工具。 If you don't control the host application, you can't control the app domain you're loaded into.
如果您不控制主机应用程序,则无法控制要加载到的应用程序域。 In theory, the app domain is irrelevant though: code your plugin such that exceptions don't bubble out of your classes, and you'll likely end up with much more durable, much better designed code.
从理论上讲,应用程序域是无关紧要的:对插件进行编码,以使异常不会从类中冒出来,并且最终可能会得到更加持久,设计更好的代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.