【发布时间】:2015-07-23 22:42:54
【问题描述】:
我想在我自己引用的程序集中包含用于分发目的的 dll 名称版本控制。例如 MyGreat.dll 变为 MyGreat.v2.dll 。
所有 MyGreat.dll 版本(包括 MyGreat.v.x.x.dll)中的命名空间都是 MyGreat。
在 Visual Studio 中,我可以添加对任一文件名的引用,并且它可以毫无问题地构建。使用文件名 MyGreat.dll 作为引用的 dll,VS 在调试模式下运行良好。
当我使用 MyGreat.v.2.dll 作为引用的 dll 在调试模式下运行 VS 时,我收到一个错误,它找不到 MyGreat.dll 或其依赖项之一等。
我可以使用任一命名的 dll 在 Visual Studio 对象浏览器窗口中浏览该 dll。
我已经尝试了尽可能多的组合和可能性,包括“或其依赖项之一”并清理项目。
有什么想法吗?
编辑:fuslogvw 结果是:
*** Assembly Binder Log Entry (24/07/2015 @ 6:20:12 PM) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable E:\My Projects\MyProject\bin\Debug\MyProject.vshost.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = MyProject.resources, Version=14.0.2.1, Culture=en-GB, PublicKeyToken=d0c57861bf8e7fbf
(Fully-specified)
LOG: Appbase = file:///E:/My Projects/MyProject/bin/Debug/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = MyProject.vshost.exe
Calling assembly : MyProject, Version=14.0.2.1, Culture=neutral, PublicKeyToken=d0c57861bf8e7fbf.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: E:\My Projects\MyProect\bin\Debug\MyProject.vshost.exe.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: MyProject.resources, Version=14.0.2.1, Culture=en-GB, PublicKeyToken=d0c57861bf8e7fbf
LOG: The same bind was seen before, and was failed with hr = 0x80070002.
ERR: Unrecoverable error occurred during pre-download check (hr = 0x80070002).
结束编辑
【问题讨论】:
-
我不确定你是否真的以此创造价值。即使使用 Windows 资源管理器,您也可以查看版本信息。那么为什么要在名称中添加版本信息呢?
-
项目中有几个应用程序,它们经常引用同一个dll。更新一个应用程序时,为该应用程序分发新版本的 dll 变得复杂,因为它们都被添加到 GAC。还有其他选择吗?
-
"在全局程序集缓存中可以维护多个同名但版本信息不同的程序集副本。" GAC 被设计为摆脱 DLL 地狱的方法。 ("msdn.microsoft.com/en-us/library/6axd4fx6(v=vs.110).aspx")
标签: .net visual-studio dll