同一文件的.NET的DLL依赖文件、NET、DLL

2023-09-03 07:18:56 作者:酒伴我

我升级了一个网站,这个错误被greated:

I upgraded one of our websites and were greated by this error:

=== Pre-bind state information ===
LOG: User = NT AUTHORITY\NETWORK SERVICE
LOG: DisplayName = <assembly>, Version=2.0.42.64, Culture=neutral, PublicKeyToken=c445f6f924945bd1
(Fully-specified)
LOG: Appbase = file:///E:/Web/
LOG: Initial PrivatePath = E:\Web\bin
Calling assembly : <assembly>, Version=2.0.42.67, Culture=neutral, PublicKeyToken=c445f6f924945bd1.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: E:\Web\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework\v2.0.50727\Aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Post-policy reference: <assembly>, Version=2.0.42.64, Culture=neutral, PublicKeyToken=c445f6f924945bd1
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/root/5ee48cb7/31fcfc81/<assembly>.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/root/5ee48cb7/31fcfc81/<assembly>/<assembly>.DLL.
LOG: Attempting download of new URL file:///E:/Web/bin/<assembly>.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Revision Number
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

其中,&LT;装配&GT; 是组装的名字

如果我读这正确的组装(0.67)试图加载本身,而是previous(0.64),并没有因为明显的文件不能有2个版本...

If i read this correctly the assemble(.67) is trying to load itself, but the previous(.64) and is failing because the obviously a file can't have 2 versions...

什么会导致这个问题? 这是我的配置或组装的编译是错的?

What can cause this problem? Is it my configuration or the assembly's compilation that is wrong?

推荐答案

我发现了错误信息的原因,现在,它张贴在这里,所以它可能会帮助别人。

I've found the reason for the error message now and posting it here so it might help others.

有两个组件与循环依赖,其中一人没有严格的版本检查:

There were two assemblies with cyclic dependency, where one of them didn't have strict revision check:

a1(.67) -> a2(.11) -> a1(.64)

其中, A1 A2 是组件的名称,并在括号中的数字是修订。

Where a1 and a2 are the assembly names and the number in the brackets are the revisions.

所以真正发生的事情是,第一个组件加载一个旧组件,这反过来又尝试加载旧的版本组件之一。那么错误信息会告诉你, A1(0.67)尝试加载 A1(0.64),并跳过装载组件的全产业链。

So what really happens is that the first assembly is loading an old assembly, which in turn tries to load the old revision of assembly one. Then the error message will tell you that a1(.67) tries to load a1(.64), and skips the whole chain of loading assemblies.

要帮助这个调试A1 应该是严密的关于 A2 怎样修改应加载。那么错误信息会告诉你, A2 也老了。

To help with debugging of this a1 should be strict about what revision of a2 that should be loaded. Then the error message will tell you that a2 is old.