有没有一种方法使用一个DLL版本给力? [英] Is there a way to force using a dll version?

查看:142
本文介绍了有没有一种方法使用一个DLL版本给力?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法强制特定DLL版本的使用情况如何?从在app.config?

Is there a way to force the usage of a specific dll version? from the app.config?

(背景故事),我们使用的是SQL精简3.5,而不能出于商业原因(是的,我知道)迁移到SQL精简3.5 SP1的时刻。我们对System.Data.SqlServerCe和我们构建目录中的所有非托管的dll,但如果SP1安装,应用程序加载和使用SP1管理DLL(通过扩展,我认为非托管之辈)。

(backstory) We are using SQL Compact 3.5, and cannot for business reasons (yea, I know) move to SQL Compact 3.5 SP1 for the moment. We have the System.Data.SqlServerCe and all the unmanaged dlls in our build directory, but if SP1 is installed, the app loads up and uses the SP1 managed dll (and by extension, I assume the unmanaged ones too).

在pre-SP1 DLL的版本号为3.5.0.0,SP1版本为3.5.1.0

The version number of the pre-sp1 dll is 3.5.0.0, the sp1 version is 3.5.1.0

我已经设置了基准对System.Data.SqlServerCe为CopyLocal = true并且特定版本=真实的,但它仍然使用SP1版本,即使在pre-SP1版本是在我们的build目录(假设它使用来自海关总署的一个)。我试着加入从GAC参考,以及手动进入文件系统,并直接引用该dll。

I've set the reference to the System.Data.SqlServerCe to CopyLocal = true and Specific Version = true, but it still uses the SP1 version, even when the pre-sp1 version is in our build directory (assume its using the one from the GAC). I've tried adding the reference from the GAC, as well as manually going into the file system and referencing the dll directly.

(只是要清楚,客户端安装服务包需要它的其他软件,但我们需要继续运行安装了服务包即使在pre-SP1版本)

(just to make it clear, clients are installing the service pack for other software that needs it, but we need to still run the pre-sp1 version even when the service pack is installed)

有没有什么办法来强制.NET使用的那个,我们已经在我们构建目录?

Is there any way to force .net to use the one we have in our build directory?

更新:

我把覆盖在应用程序的配置像<一个href="http://stackoverflow.com/questions/267693/how-can-i-force-net-to-use-a-local-copy-of-an-assembly-thats-in-the-gac">this问题,但在运行程序集绑定日志查看器给了我这样的:

I put an override in the app config like this question, but running the assembly binding log viewer gives me this:

LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Projects\ConsoleApplication11\bin\Debug\ConsoleApplication11.exe.Config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Redirect found in application configuration file: 3.5.0.0 redirected to 3.5.0.0.
LOG: Publisher policy file is found at C:\Windows\assembly\GAC_MSIL\policy.3.5.System.Data.SqlServerCe\3.5.0.0__89845dcd8080cc91\publisher.config.
LOG: Publisher policy file redirect is found: 3.5.0.0 redirected to 3.5.1.0.
LOG: ProcessorArchitecture is locked to MSIL.
LOG: Post-policy reference: System.Data.SqlServerCe, Version=3.5.1.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL
LOG: Found assembly by looking in the GAC.
LOG: Binding succeeds. Returns assembly from C:\Windows\assembly\GAC_MSIL\System.Data.SqlServerCe\3.5.1.0__89845dcd8080cc91\System.Data.SqlServerCe.dll.
LOG: Assembly is loaded in default load context.

它看起来像配置为3.5.1装配在GAC是压倒一切的。从我的app.config迫使这一问题的任何方式?

It looks like the config for the 3.5.1 assembly in the GAC is overriding it. Any way of forcing the issue from my app.config?

推荐答案

我已经找到了解决方案。纵观链接在亨克的回答(这里 ),以及融合日志的输出,它似乎是3.5 SP1安装程序安装,迫使装载的sp1的DLL的发布者策略文件,即使当$ P $对 - SP1的dll被请求。

I've found the solution. Looking at the link in Henk's answer (here), and the output of the fusion log, it seems that the 3.5 SP1 installer installs a publisher policy file that forces loading of the sp1 dll, even when the pre-sp1 dll is requested.

在App.config把它告诉.NET忽略出版商策略,并使用3.5.0.0版本结束了:

Putting this in the app.config tells .net to ignore the publisher policy, and ends up using the 3.5.0.0 version:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <runtime>
	    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
		    <dependentAssembly>
			    <assemblyIdentity name="System.Data.SqlServerCe" publicKeyToken="89845dcd8080cc91" />
			    <publisherPolicy apply="no"/>
		    </dependentAssembly>
	    </assemblyBinding>
    </runtime>
</configuration>

这篇关于有没有一种方法使用一个DLL版本给力?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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