Microsoft应用程序块的DLL V2和V4.1引用 [英] Microsoft Application block DLL V2 and V4.1 references
问题描述
我的应用程序所引用微软企业库V4.1而老DLL(外部应用程序)的一个要求引用微软企业库V2.0。我确信,我可以这两个组件在GAC注册和应用程序将开始读取所需相关的DLL,但不是一个解决方案,对我们来说,因为我们的安全专家不同意在接受这个解决方案。
有没有使用webconfig什么办法,我可以专门指定较早的DLL使用V2.0而整个应用程序使用4.V0。
请注意:我们正在使用Asp.net的Visual Studio C#
帮助急需! 谢谢
更新:
试图用privatePath探测的解决方案:
< assemblyBinding的xmlns =瓮:架构 - 微软COM:asm.v1>
<探测privatePath =仓; ExtDLL/>
< / assemblyBinding>
我的Web文件夹现在已经包含V2.0.0.0的DLL微软企业库ExtDLL文件夹,但我还是当我调用这是使用V2.0.0.0组装外部DLL的功能得到下面的异常:
... System.IO.FileLoadException:未能加载文件或程序集Microsoft.Practices.EnterpriseLibrary.Data,版本= 2.0.0.0,文化=中性公钥=空'它的依赖或之一。找到的程序集清单定义不匹配的程序集引用。 (从HRESULT异常:0x80131040)
您是否尝试过这样的事情?这是目前我使用的支持多个版本的DLL的应用程序,同时避免了GAC的技术。
< assemblyBinding的xmlns =瓮:架构 - 微软COM:asm.v1>
< dependentAssembly>
< assemblyIdentity名=MyLibrary的公钥=605f591b87e816bd/>
< codeBase的版本=1.0.0.0HREF =./ V1 / MyLibrary.dll/>
< codeBase的版本=2.0.0.0HREF =./ V2 / MyLibrary.dll/>
< / dependentAssembly>
< / assemblyBinding>
该请确保您有:
- 您的DLL强命名
- 在适当的目录结构(V1 / MyLibrary.dll和v2 / MyLibrary.dll)是你的二进制文件夹
- 没有出现在这些子文件夹,直接在您的二进制文件夹应该出现在的DLL。
这是一个简单的解决方案 - 但我会建议是,他们将在GAC,如您在实际工作命名的子文件夹相同的:
./在MyLibrary / 1.0.0.0__605f591b87e816bd / MyLibrary.dll
./在MyLibrary / 2.0.0.0__605f591b87e816bd / MyLibrary.dll
./在MyLibrary / 2.0.0.0_en_605f591b87e816bd / MyLibrary.dll(这是一个构建的是一个例子 本地化,卫星组件总是出现这样的)
My application is referencing Microsoft Enterprise library V4.1 while one of the older DLL (external application) requires a reference to Microsoft Enterprise library V2.0. I know for sure that i can register both of these assemblies in the GAC and the application will start reading relevant DLL as required but that is not a solution for us since our security expert is not agreeing upon accepting this solution.
Is there any way using the webconfig where I can specifically specify that the Older DLL use V2.0 while the entire application uses 4.V0.
note : We're using Asp.net visual Studio C#
Help needed desperately ! Thanks
Update :
Tried the solution of using privatePath probing :
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="bin;ExtDLL"/>
</assemblyBinding>
My Web folder now has ExtDLL folder which contains V2.0.0.0 Dlls for Microsoft Enterprise library, but i still get the following exception as soon as i call the external DLL's function which is using V2.0.0.0 assembly:
...System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Have you tried something like this? This is currently the technique that I use for supporting multiple versions of DLL in an application, whilst avoiding the GAC.
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="MyLibrary" publicKeyToken="605f591b87e816bd"/>
<codeBase version="1.0.0.0" href="./v1/MyLibrary.dll"/>
<codeBase version="2.0.0.0" href="./v2/MyLibrary.dll"/>
</dependentAssembly>
</assemblyBinding>
The make sure you have:
- Your DLLs are strongly named
- the appropriate directory structure (v1/MyLibrary.dll and v2/MyLibrary.dll) is in your binary folder
- None of the DLLs that appear in these 'subfolders' should appear directly within your binary folder.
This is a simple solution - but I would reccomend that you actuall name your subfolders the same are they would be in the GAC, such as:
./MyLibrary/1.0.0.0__605f591b87e816bd/MyLibrary.dll
./MyLibrary/2.0.0.0__605f591b87e816bd/MyLibrary.dll
./MyLibrary/2.0.0.0_en_605f591b87e816bd/MyLibrary.dll (this is an example of a build that is localized, satellite assemblies would always appear like this)
这篇关于Microsoft应用程序块的DLL V2和V4.1引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!