如何告诉我的ASP.NET应用程序使用任何版本的强命名程序集?

时间:2022-03-22 04:16:38

I have an ASP.NET application that uses a custom .NET library (a .DLL file). That .DLL file is strongly named. The library has frequent small updates, and I would like to be able to update this .DLL without recompiling the application. The application has to be precompiled because I do not want to give the source of it to my customers (not that it can't be decompiled, but that's besides the point).

我有一个使用自定义.NET库(.DLL文件)的ASP.NET应用程序。该.DLL文件名称很强。该库经常有小的更新,我希望能够在不重新编译应用程序的情况下更新此.DLL。该应用程序必须进行预编译,因为我不想将它的来源提供给我的客户(不是它不能被反编译,但除此之外)。

Can this be done somehow? Currently I just get an error that the .DLL is of the wrong version.

这可以以某种方式完成吗?目前我只是得到一个错误,.DLL是错误的版本。

3 个解决方案

#1


You can supply them with an updated config file to go with the new dll. This config needs to have a custom version policy redirecting requests from one dll to the other. See this article for more information.

您可以为它们提供更新的配置文件以使用新的dll。此配置需要具有自定义版本策略,将请求从一个dll重定向到另一个dll。有关更多信息,请参阅此文章。


Actually this article has more information on the whole process and the different levels that you can define a version policy at.

实际上,本文提供了有关整个过程的更多信息以及可以在其中定义版本策略的不同级别。

#2


You could use reflection to dinamically load the assembly at runtime. Activator.CreateInstance should do the trick.

您可以使用反射在运行时以动态方式加载程序集。 Activator.CreateInstance应该可以解决问题。

IMyInterface myObject = (IMyInterface)Activator.CreateInstance( "TheAssemblyName",
                                            "TheTypeName",
                                            null )

If you are using .Net 3.5 you can use the Add-ins and Extensibility. Take a look here: http://msdn.microsoft.com/en-us/library/bb384241.aspx

如果您使用的是.Net 3.5,则可以使用加载项和扩展性。看看这里:http://msdn.microsoft.com/en-us/library/bb384241.aspx

#3


Maybe you can just put the strongly typed dll's in the gac, end do dll versioning, so the older version will be always available and the new one's will only be used by the new compiled apps, and the older apps will be used their old dll version until they are compiled and deployed again.

也许你可以把强类型的dll放在gac中,结束做dll版本控制,所以旧版本将始终可用,新版本只会被新编译的应用程序使用,而较旧的应用程序将使用旧的dll版本,直到它们再次编译和部署。

Hope this maybe helps.

希望这可能有所帮助。

#1


You can supply them with an updated config file to go with the new dll. This config needs to have a custom version policy redirecting requests from one dll to the other. See this article for more information.

您可以为它们提供更新的配置文件以使用新的dll。此配置需要具有自定义版本策略,将请求从一个dll重定向到另一个dll。有关更多信息,请参阅此文章。


Actually this article has more information on the whole process and the different levels that you can define a version policy at.

实际上,本文提供了有关整个过程的更多信息以及可以在其中定义版本策略的不同级别。

#2


You could use reflection to dinamically load the assembly at runtime. Activator.CreateInstance should do the trick.

您可以使用反射在运行时以动态方式加载程序集。 Activator.CreateInstance应该可以解决问题。

IMyInterface myObject = (IMyInterface)Activator.CreateInstance( "TheAssemblyName",
                                            "TheTypeName",
                                            null )

If you are using .Net 3.5 you can use the Add-ins and Extensibility. Take a look here: http://msdn.microsoft.com/en-us/library/bb384241.aspx

如果您使用的是.Net 3.5,则可以使用加载项和扩展性。看看这里:http://msdn.microsoft.com/en-us/library/bb384241.aspx

#3


Maybe you can just put the strongly typed dll's in the gac, end do dll versioning, so the older version will be always available and the new one's will only be used by the new compiled apps, and the older apps will be used their old dll version until they are compiled and deployed again.

也许你可以把强类型的dll放在gac中,结束做dll版本控制,所以旧版本将始终可用,新版本只会被新编译的应用程序使用,而较旧的应用程序将使用旧的dll版本,直到它们再次编译和部署。

Hope this maybe helps.

希望这可能有所帮助。