动态更改 .NET 中的 DLL
我正在尝试找到一种解决方案,用于从 winform (C#.NET) 应用程序中的文件夹或数据库动态加载更新的 dll。
假设我有一个 exe(例如 MainApplication.exe),它将充当真正业务逻辑的包装器/容器。业务逻辑将位于程序集内(例如 Business.dll)。现在,如果有新版本的 Business.dll 可用,我将如何在运行时动态更改 Business.dll。
提前致谢, 拉吉夫·兰詹·拉尔
I am trying to find a solution for dynamically loading the updated dll from a folder or database in a winform (C#.NET) application.
Suppose I have an exe (say MainApplication.exe), which will act as a wrapper/container for the real business logic. The business logic will sit inside the assembly (say Business.dll). Now, how would I dynamically change the Business.dll at runtime in the event of new version of Business.dll is available.
Thanks in Advance,
Rajeev Ranjan Lall
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须将程序集加载到另一个 AppDomain 中,这是稍后卸载它的唯一方法。
您还需要与该代码对话并让该代码与您对话的方法,因此您需要一个插件可以与之对话的 API 以及要实现的接口。
这是 很好的例子,我刚刚用谷歌搜索过。希望有帮助。
You have to load your assembly into another AppDomain, which is the only way to unload it later on.
You also need means to talk to that code and have that code talk back to you, so you'll need an API that your plugin can talk to and interfaces to implement.
Here's a nice example, I just googled. Hope it helps.
看看我的问题,使用 AppDomain 加载/卸载外部程序集 可能会帮助您立即进入正题。
Take a look on my question, Use AppDomain to load/unload external assemblies might help you get to the point straight away.