我应该使用哪个 dll 版本? Razor.DLL - 清单不匹配 (0x80131040)
Which dll version should I use? Razor.DLL - Manifest does not match (0x80131040)
我应该使用哪个 dll,我从哪里获取它?
Stack Overflow 中的多个答案解释了问题以及如何更正此错误的解决方案,但 none 告诉我应该使用哪个版本。所以这是我的问题 - 它会帮助所有有类似问题的人:
我得到一个
The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
我在 Nancy Razor 的 Nuget 包之后的 Visual Studio 项目中引用了 System.Web.Razor
版本 4.0.30319
查看bin文件夹我有一个System.Web.Razor,文件版本为2.0.20715.0
,我不确定文件版本与软件版本有什么关系...
Microsoft.AspNet.Razor 包版本 2.0.30506.0 是通过 Nuget 与 Nancy.ViewEngines.Razor 包一起安装的。
在 C:\Windows
下查找,我有一整套 System.Web.Razor.DLL 的临时位置列表都在 Microsoft.NET\Framework\v4.0.30319.0\Temporary ASP.NET Files\
下,只有一个看似不同的 System.Web.Razor.DLL 版本目录中的文件:Microsoft.NET\assembly\GAC_MSIL\System.Web.Razor\v4_02.0.0.0_31bf....
这是我的日志
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\me\Documents\Dev\MyProj\web.config
LOG: Using host configuration file: C:\Users\me\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\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/Framework/v4.0.30319/Temporary ASP.NET Files/root/a98e1c21/1e31926/System.Web.Razor.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/a98e1c21/1e31926/System.Web.Razor/System.Web.Razor.DLL.
LOG: Attempting download of new URL file:///C:/Users/me/Documents/Dev/MyProj/bin/System.Web.Razor.DLL.
LOG: Using application configuration file: C:\Users\me\Documents\Dev\MyProj\web.config
LOG: Using host configuration file: C:\Users\me\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 2.0.0.0 redirected to 3.0.0.0.
LOG: Post-policy reference: System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/a98e1c21/1e31926/System.Web.Razor.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/a98e1c21/1e31926/System.Web.Razor/System.Web.Razor.DLL.
LOG: Attempting download of new URL file:///C:/Users/Me/Documents/Dev/MyProj/bin/System.Web.Razor.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
我尝试删除 NUGET 清理项目,删除 obj 和 bin 目录,然后重新 Nancy Razor 的 NUGET 并重建。
我的项目在System.Web.Razor.DLL 上的引用列表属性中说要将dll 复制到本地。
无济于事。
所以我希望手动设置对正确文件的引用。那个正确的文件在哪里?
或者我必须对 GAC 做些什么吗?它会干扰我的 VS 2013 IIS Express 吗?
2015 年 12 月 29 日编辑:
我的网络配置如下:
<configSections>
<sectionGroup name="system.web.webPages.razor"
type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup,
System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35">
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection,
System.Web.WebPages.Razor, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=31BF3856AD364E35"
requirePermission="false" />
v4.0.30319.0下临时目录下的dll文件都是同一个文件的副本。参考资料中的属性(如果我浏览到其中一个并添加到项目的参考资料中,版本号为:3.0.0.0,运行时版本为 4.0.30319.0.
当我在References.Add-Reference form时,显示文件版本为:3.0.20826.0。
Nancy.ViewEngines.Razor
仅适用于 Razor 的 V2 / V3。您也许可以将 V4 与程序集重定向一起使用,但它完全未经测试,在 Nancy V2 发布之前,我们可能不会添加对 V4 的支持。
编辑:
我不完全确定您的引用是如何搞砸的,实际上我对 Nancy.ViewEngine.Razor
引用进行了所有升级以支持 Razor V3,并且由于 NuGet 拉错的奇怪问题做了太多测试参考。这是我做PR以来第一个关于references的issue
V3 依赖于 .NET 4.5,所以如果您的项目是 .NET 4.0 并且最近更新到 4.5,那么它可能已经引入了 V2 而没有更新到 V3,因为在检查依赖性时 V2 来自 GAC。
理论上 V2 和 V3 都应该来自 NuGet。
为了安全起见,我会删除对 Razor 和 Nancy.ViewEngines.Razor 的引用,从 web.config 文件中删除配置。然后从 Nuget re-install,这应该从 NuGet 中提取并从 NuGet 中提取 Razor。然后一切都应该正确配置。
我应该使用哪个 dll,我从哪里获取它? Stack Overflow 中的多个答案解释了问题以及如何更正此错误的解决方案,但 none 告诉我应该使用哪个版本。所以这是我的问题 - 它会帮助所有有类似问题的人:
我得到一个
The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
我在 Nancy Razor 的 Nuget 包之后的 Visual Studio 项目中引用了 System.Web.Razor
版本 4.0.30319
查看bin文件夹我有一个System.Web.Razor,文件版本为2.0.20715.0
,我不确定文件版本与软件版本有什么关系...
Microsoft.AspNet.Razor 包版本 2.0.30506.0 是通过 Nuget 与 Nancy.ViewEngines.Razor 包一起安装的。
在 C:\Windows
下查找,我有一整套 System.Web.Razor.DLL 的临时位置列表都在 Microsoft.NET\Framework\v4.0.30319.0\Temporary ASP.NET Files\
下,只有一个看似不同的 System.Web.Razor.DLL 版本目录中的文件:Microsoft.NET\assembly\GAC_MSIL\System.Web.Razor\v4_02.0.0.0_31bf....
这是我的日志
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\me\Documents\Dev\MyProj\web.config
LOG: Using host configuration file: C:\Users\me\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\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/Framework/v4.0.30319/Temporary ASP.NET Files/root/a98e1c21/1e31926/System.Web.Razor.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/a98e1c21/1e31926/System.Web.Razor/System.Web.Razor.DLL.
LOG: Attempting download of new URL file:///C:/Users/me/Documents/Dev/MyProj/bin/System.Web.Razor.DLL.
LOG: Using application configuration file: C:\Users\me\Documents\Dev\MyProj\web.config
LOG: Using host configuration file: C:\Users\me\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 2.0.0.0 redirected to 3.0.0.0.
LOG: Post-policy reference: System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/a98e1c21/1e31926/System.Web.Razor.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/a98e1c21/1e31926/System.Web.Razor/System.Web.Razor.DLL.
LOG: Attempting download of new URL file:///C:/Users/Me/Documents/Dev/MyProj/bin/System.Web.Razor.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
我尝试删除 NUGET 清理项目,删除 obj 和 bin 目录,然后重新 Nancy Razor 的 NUGET 并重建。
我的项目在System.Web.Razor.DLL 上的引用列表属性中说要将dll 复制到本地。
无济于事。
所以我希望手动设置对正确文件的引用。那个正确的文件在哪里?
或者我必须对 GAC 做些什么吗?它会干扰我的 VS 2013 IIS Express 吗?
2015 年 12 月 29 日编辑:
我的网络配置如下:
<configSections>
<sectionGroup name="system.web.webPages.razor"
type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup,
System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35">
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection,
System.Web.WebPages.Razor, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=31BF3856AD364E35"
requirePermission="false" />
v4.0.30319.0下临时目录下的dll文件都是同一个文件的副本。参考资料中的属性(如果我浏览到其中一个并添加到项目的参考资料中,版本号为:3.0.0.0,运行时版本为 4.0.30319.0.
当我在References.Add-Reference form时,显示文件版本为:3.0.20826.0。
Nancy.ViewEngines.Razor
仅适用于 Razor 的 V2 / V3。您也许可以将 V4 与程序集重定向一起使用,但它完全未经测试,在 Nancy V2 发布之前,我们可能不会添加对 V4 的支持。
编辑:
我不完全确定您的引用是如何搞砸的,实际上我对 Nancy.ViewEngine.Razor
引用进行了所有升级以支持 Razor V3,并且由于 NuGet 拉错的奇怪问题做了太多测试参考。这是我做PR以来第一个关于references的issue
V3 依赖于 .NET 4.5,所以如果您的项目是 .NET 4.0 并且最近更新到 4.5,那么它可能已经引入了 V2 而没有更新到 V3,因为在检查依赖性时 V2 来自 GAC。
理论上 V2 和 V3 都应该来自 NuGet。
为了安全起见,我会删除对 Razor 和 Nancy.ViewEngines.Razor 的引用,从 web.config 文件中删除配置。然后从 Nuget re-install,这应该从 NuGet 中提取并从 NuGet 中提取 Razor。然后一切都应该正确配置。