我刚刚在我的asp.net应用程序(.net Framework 4.7)中添加了Automapper,以期希望能够代替我总是需要做的一些繁琐的手动映射。
我现在在使用System.ValueTuple版本时遇到很多问题。我注意到我有一个System.ValueTuple v4.5.0
的nuget包。如果我研究自己的解决方案packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll
,我会认为它是版本4.6.26515.06。如果查看其中一个项目,则有这个nuget包(将Automapper添加到其中的那个),但是,当我在构建后查看bin
文件夹时,我的版本是4.6.25514.4
,即nuget软件包具有的较旧版本
当我在构建机器上构建应用程序时,会拾取4.6011.3
。还有一个版本!!!
我无法卸载nuget软件包,因为它表示Automapper对此具有依赖性。
当用户运行该应用程序时,他们使用
进入死亡的黄屏 Could not load file or assembly 'System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
有人知道如何对这个System.ValueTuple进行排序,并且知道为什么我似乎到处都是随机版本吗?
谢谢!
[EDIT1]
按照@Lucian的建议,我在自己的开发机和另一台无法运行的机器上都运行了Fusion工具。
我注意到,在我的计算机上,在我的bin中找到的ValueTuple DLL声称是版本4.0.2.0
,而不是文件版本。
所以我添加了...
<dependentAssembly>
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="4.0.3.0" newVersion="4.0.2.0" />
</dependentAssembly>
以前,如果在我的开发机上添加任何这些bindingRedirect
,我也会收到错误消息,但是现在,上面的命令可以正常工作了。
但是,它不在其他生产(内部测试)计算机上。从那台机器上,我得到以下输出(一旦我终于使Fusion工作了)……
*** Assembly Binder Log Entry (20/11/2018 @ 9:16:49 AM) ***
The operation failed.
Bind result: hr = 0x80131040. No description available.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable c:\windows\system32\inetsrv\w3wp.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = System.ValueTuple
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: System.ValueTuple | Domain ID: 6
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/inetpub/wwwroot/MyApp/
LOG: Initial PrivatePath = C:\inetpub\wwwroot\MyApp\bin
LOG: Dynamic Base = C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\MyApp\0718df87
LOG: Cache Base = C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\MyApp\0718df87
LOG: AppName = ab2266c7
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\inetpub\wwwroot\MyApp\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/MyApp/0718df87/ab2266c7/System.ValueTuple.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/MyApp/0718df87/ab2266c7/System.ValueTuple/System.ValueTuple.DLL.
LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/MyApp/bin/System.ValueTuple.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\inetpub\wwwroot\MyApp\bin\System.ValueTuple.dll
LOG: Entering download cache setup phase.
LOG: Assembly Name is: System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
LOG: A partially-specified assembly bind succeeded from the application directory. Need to re-apply policy.
LOG: Using application configuration file: C:\inetpub\wwwroot\MyApp\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 4.0.3.0 redirected to 4.0.2.0.
LOG: Post-policy reference: System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
LOG: GAC Lookup was unsuccessful.
LOG: The post-policy assembly reference requires probing again.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/MyApp/0718df87/ab2266c7/System.ValueTuple.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/MyApp/0718df87/ab2266c7/System.ValueTuple/System.ValueTuple.DLL.
LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/MyApp/bin/System.ValueTuple.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\inetpub\wwwroot\MyApp\bin\System.ValueTuple.dll
LOG: Entering download cache setup phase.
LOG: Assembly Name is: System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
WRN: Comparing the assembly name resulted in the mismatch: Build Number
ERR: The assembly reference did not match the assembly definition found.
ERR: Setup failed with hr = 0x80131040.
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
*** Assembly Binder Log Entry (20/11/2018 @ 9:16:49 AM) ***
The operation failed.
Bind result: hr = 0x80131040. No description available.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable c:\windows\system32\inetsrv\w3wp.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = System.ValueTuple
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: System.ValueTuple | Domain ID: 6
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/inetpub/wwwroot/MyApp/
LOG: Initial PrivatePath = C:\inetpub\wwwroot\MyApp\bin
LOG: Dynamic Base = C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\MyApp\0718df87
LOG: Cache Base = C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\MyApp\0718df87
LOG: AppName = ab2266c7
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\inetpub\wwwroot\MyApp\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/MyApp/0718df87/ab2266c7/System.ValueTuple.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/MyApp/0718df87/ab2266c7/System.ValueTuple/System.ValueTuple.DLL.
LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/MyApp/bin/System.ValueTuple.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\inetpub\wwwroot\MyApp\bin\System.ValueTuple.dll
LOG: Entering download cache setup phase.
LOG: Assembly Name is: System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
LOG: A partially-specified assembly bind succeeded from the application directory. Need to re-apply policy.
LOG: Using application configuration file: C:\inetpub\wwwroot\MyApp\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 4.0.3.0 redirected to 4.0.2.0.
LOG: Post-policy reference: System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
LOG: GAC Lookup was unsuccessful.
LOG: The post-policy assembly reference requires probing again.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/MyApp/0718df87/ab2266c7/System.ValueTuple.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/MyApp/0718df87/ab2266c7/System.ValueTuple/System.ValueTuple.DLL.
LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/MyApp/bin/System.ValueTuple.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\inetpub\wwwroot\MyApp\bin\System.ValueTuple.dll
LOG: Entering download cache setup phase.
LOG: Assembly Name is: System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
WRN: Comparing the assembly name resulted in the mismatch: Build Number
ERR: The assembly reference did not match the assembly definition found.
ERR: Setup failed with hr = 0x80131040.
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
我可以看到它从Redirect found in application configuration file: 4.0.3.0 redirected to 4.0.2.0.
中得到的行web.config
,而4.0.2.0
是bin文件夹中的行。这也是Dotpeek中显示的版本。
由于某种原因,它似乎试图从C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/MyApp
获取此DLL,并且它似乎以Assembly Name is: System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
结尾,然后失败了。.
WRN: Comparing the assembly name resulted in the mismatch: Build Number
ERR: The assembly reference did not match the assembly definition found.
如果我删除了此bindingRedirect
,它将报告正在寻找版本0.0.0.0
。我不知道这是怎么回事。我们正尝试重新映射到的版本4.0.2.0
在bin文件夹中!
我还删除了文件夹C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\MyApp
,但这没什么区别。
任何其他想法将不胜感激。