2011-05-12 61 views
2

好日子GAC大会版本使用基于程序Web.Config

我有一个项目,使得在GAC使用的自定义组件: 为了能够使用,我在

添加引用到我的项目
C:\WINDOWS\Microsoft.NET\assembly\GAC_MSIL\JOHN.CommonLib\v4.0_1.0.0.0__9cd884563ebafb62\JOHN.CommonLib.dll 

(CopyLocal = FALSE; SpecificVersion =假) 另外,我在它的预期运行Web.Config文件

<compilation debug="false" strict="true" explicit="true" targetFramework="4.0" > 
    <assemblies> 
    <add assembly="JOHN.CommonLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9cd884563ebafb62"/>   
    </assemblies > 
</compilation > 

加入此。问题是,当我安装新版本 我安装新版本的GAC,并更改Web.Config中相应

<add assembly="JOHN.CommonLib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=9cd884563ebafb62"/> 

JOHN.CommonLib是测试类库返回不是“1.0”或“2.0”取决于版本。

问题:如果我使用1.0进行编译,使用它的webapps总是显示“1.0”,即使我在1.0和2.0之间更改Web.Config 我希望我的web应用程序使用我写的版本在我的Web.Config

任何想法? 我也停止并在更改Web.Config之间启动AppPool。

回答

3

对于强有力的命名程序集 - 应用程序将始终绑定(如果可能)其已经构建的版本。要覆盖此绑定,您需要为程序集指定绑定重定向。有多种方法可以做到这一点 - 请参阅link。因此,使用应用程序/网络配置文件的方式之一 - 例如,

<configuration> 
    <runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
     <assemblyIdentity name="JOHN.CommonLib" 
      publicKeyToken="9cd884563ebafb62" 
      culture="en-us" /> 
     <!-- Assembly versions can be redirected in application, 
      publisher policy, or machine configuration files. --> 
     <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" /> 
     </dependentAssembly> 
    </assemblyBinding> 
    </runtime> 
</configuration> 
+0

感谢这就是我需要的!进一步谷歌搜索我遇到这个http://blogs.msdn.com/b/thottams/archive/2007/01/30/introduction-to-versioning-and-bindingredirect.aspx – John 2011-05-13 03:02:52

相关问题