Microsoft 应用程序块 DLL V2 和 V4.1 参考
我的应用程序正在引用 Microsoft Enterprise 库 V4.1,而较旧的 DLL(外部应用程序)之一需要引用 Microsoft Enterprise 库 V2.0。我确信我可以在 GAC 中注册这两个程序集,并且应用程序将开始根据需要读取相关 DLL,但这对我们来说不是一个解决方案,因为我们的安全专家不同意接受此解决方案。
有什么方法可以使用 webconfig 来明确指定旧版 DLL 使用 V2.0,而整个应用程序使用 4.V0。
注意:我们正在使用 Asp.net Visual Studio C#
迫切需要帮助! 谢谢
更新:
尝试了使用 privatePath 探测的解决方案:
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="bin;ExtDLL"/>
</assemblyBinding>
我的 Web 文件夹现在有 ExtDLL 文件夹,其中包含 Microsoft Enterprise 库的 V2.0.0.0 Dlls,但是当我调用正在使用的外部 DLL 函数时,我仍然遇到以下异常V2.0.0.0组装:
...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)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你尝试过这样的事情吗?目前,我使用这种技术来支持应用程序中的多个 DLL 版本,同时避免使用 GAC。
请确保:
这是一个简单的解决方案 - 但我建议您实际命名子文件夹,使其与 GAC 中的名称相同,例如:
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.
The make sure you have:
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:
我无法使用 probing/privatePath 或代码库配置加载两个版本的 Enterprise Library。
我能够让它工作的唯一方法是使用 自定义解析程序集加载.。
我将 2.0 程序集放置在应用程序 bin 目录中。然后我将 4.1 程序集放置在 bin 下名为 EL41 的目录中 (bin\EL41)。然后,我添加了自定义事件处理程序,尝试通过添加
到启动代码然后创建 MyResolveEventHandler 来
解析程序集,这肯定会起作用。您可以将路径放置在配置中以避免对位置进行硬编码,但我仍然感觉不对。我想知道是否有一种侵入性较小的方式来做你想做的事。
I was unable to be able to load both versions of Enterprise Library using probing/privatePath or codebase configuration.
The only way I was able to get it to work was using custom resolving of assembly loads..
I placed the 2.0 assemblies in the application bin directory. Then I placed the 4.1 assemblies in a directory called EL41 under bin (bin\EL41). I then added custom event handler to try to resolve the assembly by adding
to startup code and then creating the MyResolveEventHandler
This definitely will work. You could place the path in configuration to avoid hard coding the location but it still feels wrong to me. I wonder if there is a less intrusive way to do what you want.