简体   繁体   English

.Net中的DLL管理

[英]Dll management in .Net

I develop client application that invokes product that has multiple versions and my customers can load different versions of the product one after another. 我开发了调用具有多个版本的产品的客户端应用程序,我的客户可以一个接一个地加载不同版本的产品。

In order to support that in previous versions I created Application domain for each time user picked version. 为了支持以前的版本,我为每次用户选择的版本创建了应用程序域。

Is it the right way to do it ? 这是正确的方法吗? Do I have alternative ? 我有其他选择吗?

EDITED: Multiple versions - multiple dlls 编辑:多个版本 - 多个dll

Thank You! 谢谢!

If different versions of products reside in different DLLs, then yes, AppDomain is the right way to do it. 如果不同版本的产品驻留在不同的DLL中,那么是的,AppDomain是正确的方法。

Although make sure you don't leak the DLLs to your main domain. 虽然请确保不要将DLL泄漏到主域。

Also, run some tests to make sure you don't leak memory. 此外,运行一些测试以确保您不会泄漏内存。

UPDATE UPDATE

Alternative is to load the DLLs in another process and use RPC or service calls. 另一种方法是在另一个进程中加载​​DLL并使用RPC或服务调用。 I guess that's an overkill for your application. 我想这对你的申请来说太过分了。

I don't think the products has to reside in different AppDomains. 我不认为产品必须驻留在不同的AppDomain中。 What is the main reason for doing it that way? 这样做的主要原因是什么? Do you want your app to be able to unload particular dll, and load a new version of the same dll while running? 您是否希望您的应用能够卸载特定的dll,并在运行时加载相同dll的新版本? If not... I don't see what is the reason behind having App Domains. 如果不是......我不知道拥有App Domains背后的原因是什么。

AppDomains are usually used when you want to guarantee that memory allocated by assembly itself could be freed when assembly is unloaded. 当您想要保证在卸载程序集时可以释放程序集本身分配的内存时,通常会使用AppDomains。 It makes sens in some types of apps. 它在某些类型的应用程序中具有敏感性。 IIS uses AppDomains to manage all applications it is running (so that applications are separated). IIS使用AppDomain来管理它正在运行的所有应用程序(以便应用程序分离)。

Why not use a common interface for all versions of the product, and store information about the product itself inside (propert or whatever way you like)? 为什么不为产品的所有版本使用通用接口,并在其中存储有关产品本身的信息(属性或您喜欢的任何方式)?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM