我们的应用程序动态加载一组私有程序集,每个程序集都位于它们自己的子目录下。它们每个都有自己的依赖项,这些依赖项也在同一个子目录中。每个程序集都是强命名的,并且依赖项是相同的库,但版本不同。
MyApp
|-> Folder1\
| |->PrivateAssembly1.dll
| |->Dependency.dll Version 1.0.0.0
|
|-> Folder2\
| |->PrivateAssembly2.dll
| |->Dependency.dll Version 2.0.0.0
|
...
由于我们正在进行 xcopy 部署,因此我们不使用 GAC。
我们还probing privatePath
定义了"Folder1;Folder2"
解决任何找不到私有程序集的问题。
问题是 PrivateAssembly1.dll 似乎找到了它的依赖关系,但 PrivateAssembly2.dll 没有。或者更确切地说,它似乎试图使用 Folder1 中的 Dependency.dll 而不是 Folder2。
我知道这些问题可以通过使用 AssemblyResolve 事件手动解决,但这不是最干净的方法。还有其他我忽略的解决方案吗?
感谢您的任何想法。
更新:
Fusion Log 工具的输出:
LOG: DisplayName = Dependency, Version=1.0.0.0, Culture=neutral, PublicKeyToken=#########
(Fully-specified)
LOG: Appbase = file:///C:/Workspaces/Shell/MyApp/bin/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
...
LOG: Attempting download of new URL file:///C:/Workspaces/Shell/MyApp/bin/Dependency.DLL.
LOG: Attempting download of new URL file:///C:/Workspaces/Shell/MyApp/bin/Dependency/Dependency.DLL.
LOG: Attempting download of new URL file:///C:/Workspaces/Shell/MyApp/bin/Folder2/Dependency.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\Workspaces\Shell\MyApp\bin\Folder2\Dependency.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: Dependency, Version=2.0.0.0, Culture=neutral, PublicKeyToken=#######
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: The assembly reference did not match the assembly definition found.
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
所以基本上,它在 Folder2 中找到了一个 Dependency.dll,尝试加载它只是为了看到版本不匹配。我假设它接下来会尝试 Folder1,但它只是停在那里......