在C#中使用AppDomain中动态加载和卸载DLL [英] Using AppDomain in C# to dynamically load and unload dll

查看:929
本文介绍了在C#中使用AppDomain中动态加载和卸载DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的申请,这是关系到系统诊断中的一个,该相关的DLL将被加载并在C#动态卸载。一些搜索后,我发现一个单独的DLL不能动态加载其完整的AppDomain。所以,我要创建一个AppDomain并使用加载该DLL动态卸载。但是,我找不到任何地方我怎么能在code使用。我不能显示的应用程序code,因为这是违反公司规定。

In one of my application, which is related to system diagnostics, the related DLL is to be loaded and unloaded dynamically in C#. After some search I found that a separate DLL cannot be loaded dynamically its the complete AppDomain. So I have to create an AppDomain and use that DLL to be loaded unloaded dynamically. But I could not find anywhere how can I use that in code. I can not show the app code since it is against company rules.

有人能告诉我一些应用程序code使用它。我想加载和动态使用的AppDomain卸载DLL并调用该DLL的具体方法,该DLL没有任何入口点。

Can somebody tell me some application code to use it. I want to load and unload the dll dynamically using appdomain and call a specific method in that dll, the dll does not have any entry point.

感谢您的答案。
Ashutosh说

Thanks for answers. Ashutosh

推荐答案

谢谢你们,这里是链接,我找到答案,我quetion:

Thanks guys, here is link where i found answer to my quetion:

<一个href=\"http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/a6a896ca-8905-41fb-8f52-7f39e89c9a91/\"相对=nofollow>在MSDN论坛描述组件的装载和卸载动态

其他的dll可以动态加载并使用另一个类确实在装配装载组件以及和调用方法卸载...
AppDomain.CreateInstanceAndUnwrap一般要输入从当前项目或一般当前命名空间组件。要解决,我需要Assembly.LoadFrom();在其它的类中使用,并创建应用程序域,并使用AppDomain中的对象这个类的实例作为链接给出。

The other dll can be dynamically loaded and unloaded using another class which does load assembly and and call methods in that assembly... AppDomain.CreateInstanceAndUnwrap generally wants input as assemblies from current project or generally current namespace. to solve that i need Assembly.LoadFrom(); to be used in some other class and create AppDomain and create instance of this class using AppDomain object as given in link.

感谢乌拉圭回合答复家伙。

Thanks for ur replies guys.

这篇关于在C#中使用AppDomain中动态加载和卸载DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆