pet*_*erc 5 .net asp.net automapper
我刚刚将Automapper添加到我的 asp.net 应用程序 (.net Framework 4.7),希望能够取代我总是需要执行的一些繁琐的手动映射。
我现在在 System.ValueTuple 版本方面遇到很多问题。我注意到我有一个 nuget 包System.ValueTuple v4.5.0。如果我查看我的解决方案,packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll我会看到版本为 4.6.26515.06。如果我查看其中一个项目,我有这个 nuget 包(我添加 Automapper 的那个),但是,当我在bin构建后查看我的文件夹时,我有 version 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)
Run Code Online (Sandbox Code Playgroud)
有谁知道如何整理这个 System.ValueTuple,并知道为什么我似乎到处都得到它的随机版本?
提前致谢!
[编辑1]
按照@Lucian的建议,我在我的开发机器和另一台它不起作用的机器上运行了Fusion工具。
我注意到,在我的机器上,在我的 bin 中找到的 ValueTuple DLL 声称是 version 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>
Run Code Online (Sandbox Code Playgroud)
以前,在我的开发机器上,如果我添加其中任何一个,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.
Run Code Online (Sandbox Code Playgroud)
Redirect found in application configuration file: 4.0.3.0 redirected to 4.0.2.0.我可以看到它从 中获取的行web.config,并且4.0.2.0应该位于 bin 文件夹中。这也是 Dotpeek 中出现的版本。
由于某种原因,它似乎尝试从 获取此 DLL C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/MyApp,并且似乎最终失败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.
Run Code Online (Sandbox Code Playgroud)
如果我删除它bindingRedirect,它就会报告正在寻找版本0.0.0.0。我不知道这里发生了什么事。我们尝试重新映射到的版本,即4.0.2.0,位于 bin 文件夹中!
我也删除了该文件夹C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\MyApp,但这没有什么区别。
任何其他想法将不胜感激。
| 归档时间: |
|
| 查看次数: |
3251 次 |
| 最近记录: |