重定向程序集版本,以不同的CLR / GAC [英] Redirecting Assembly versions to a different CLR/GAC

查看:297
本文介绍了重定向程序集版本,以不同的CLR / GAC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有关于2 CLR版本的问题,即第2版和.NET框架版本4,使用不同的GAC位置。我建立了一个客户端应用程序,它从V2 GAC引用程序集X(C:\ WINDOWS \组装)。我现在更新组件的X在.NET框架的V4运行(C:\ WINDOWS \ Microsoft.NET \组装),但是,我不想重新编译的客户端应用程序。请注意,组装X,从V2 GAC安装到V4 GAC之前被删除。

I have a question regarding the 2 CLR versions, i.e. version 2 and version 4 of the .NET framework, which use different GAC locations. I have a client application built which references an assembly "X" from the v2 GAC (C:\Windows\Assembly). I am now updating the assembly "X" to run on v4 of the .NET framework (C:\Windows\Microsoft.NET\assembly), however, I do not want to recompile the client application. Note, assembly "X" is removed from the v2 GAC before installing the to v4 GAC.

是否有可能创建一个它用来居住在CLR版本2的CLR版本4的组件重定向出版商策略文件?如果是这样,这是怎么实现的呢?

Is it possible to create a publisher policy file which redirects an assembly which used to reside in version 2 of the CLR to version 4 of the CLR? If so, how is this achieved?

我已经搜查了MSDN,并了解存在这样的情况,你可以指定.NET Framework版本的assemblyBinding元素上appliesTo领域,但这似乎涵盖了整个绑定。

I have searched the MSDN, and understand there is an appliesTo field on the assemblyBinding element where you can specify the version of the .NET framework, but this seems to encompass the whole bind.

我想是这样的:

<bindingRedirect oldVersion="1.0.0.0" .Net 2 newVersion="2.0.0.0" .Net 4/>

我在这里读 http://msdn.microsoft.com/en-美国/杂志/ dd727509.aspx 的CLR 2.0版的应用程序现在还无法看到在GAC CLR 4.0版组件。但是,您可以强制应用程序使用,以使用更新的CLR:

I have read here http://msdn.microsoft.com/en-us/magazine/dd727509.aspx that CLR v2.0 applications now cannot see CLR v4.0 assemblies in the GAC. However, you can force an app to use the updated CLR using:

<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" />

所以将这种混合物加上发行政策足够了,或者是有另一种方式?

So would a mixture of this plus the publisher policy suffice, or is there another way?

推荐答案

这里的决定因素是你的客户端应用程序在其下运行的CLR版本。如果是V2再有就是你可以为了使V4组件可用,甚至可以看到它什么都不做。如果它在V4 CLR中运行,那么它会自动尝试先解决在V4 GAC集引用。

The determining factor here is which version of the CLR your client app is running under. If it's v2 then there's nothing you can do in order to make v4 assemblies usable or even visible to it. If it does run under the v4 CLR then it would automatically try to resolve assembly references in the v4 GAC first.

好消息是,有没有需要重新编译,以达到你的客户端应用程序。你可以简单地迫使它的.Net 4下运行,加入到这个应用程序的配置文件:

The good news is, there is not need for you to recompile your client app in order to achieve that. You can simply force it to run under .Net 4 by adding this to the app's config file:

<configuration>
  <startup>
    <supportedRuntime version="v4.0" />
  </startup>
</configuration>

这应该给你你想要的东西。

This should give you what you wanted.

这篇关于重定向程序集版本,以不同的CLR / GAC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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