Exception 我应该使用哪个dll版本?Razor.DLL-清单不匹配(0x8013100)

Exception 我应该使用哪个dll版本?Razor.DLL-清单不匹配(0x8013100),exception,razor,dll,nancy,Exception,Razor,Dll,Nancy,我应该使用哪个dll,从哪里获取它? Stack Overflow中的多个答案解释了问题以及如何更正此错误的解决方案,但没有一个告诉我应该使用哪个版本。因此,我的问题是——它将帮助所有有类似问题的人: 我得到一份工作 定位的程序集的清单定义与程序集引用不匹配。(HRESULT的例外:0x8013100) 在Nancy Razor包的Nuget之后,我在Visual Studio项目中引用了版本为4.0.30319的System.Web.Razor 查看bin文件夹,我有一个System.Web.

我应该使用哪个dll,从哪里获取它? Stack Overflow中的多个答案解释了问题以及如何更正此错误的解决方案,但没有一个告诉我应该使用哪个版本。因此,我的问题是——它将帮助所有有类似问题的人:

我得到一份工作

定位的程序集的清单定义与程序集引用不匹配。(HRESULT的例外:0x8013100)

在Nancy Razor包的Nuget之后,我在Visual Studio项目中引用了版本为4.0.30319的
System.Web.Razor

查看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并重建

System.Web.Razor.DLL上我的项目的引用列表属性表示要在本地复制DLL

无济于事

因此,我希望手动将引用设置为正确的文件。正确的文件在哪里

还是我要对GAC做点什么?它是否会干扰我从VS 2013开始的IIS Express


2015年12月29日编辑:

我的web配置包含以下内容:

  <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表单中时,它向我显示文件版本为:3.0.20826.0。

Nancy.ViewEngines.Razor
仅适用于Razor的V2/V3。您可以将V4与程序集重定向一起使用,但它完全未经测试,在Nancy V2发布之前,我们可能不会添加对V4的支持

编辑:

我不完全确定你的参考资料是怎么搞砸的,我实际上升级了Nancy.ViewEngine.Razor的所有参考资料以支持Razor的V3,并且做了太多的测试,因为NuGet拉错了参考资料,这是我做PR后第一个关于参考资料的问题

V3依赖于.NET 4.5,因此如果您的项目是.NET 4.0并且最近更新为4.5,那么它可能已经拉入了V2,而没有将其更新为V3,因为在检查依赖关系时V2来自GAC

理论上,V2和V3都应该来自NuGet


为了安全起见,我会删除对Razor和Nancy.ViewEngines.Razor的引用,从web.config文件中删除配置。然后从Nuget重新安装,这应该从Nuget中提取,也从Nuget中提取Razor。然后所有内容都应该正确配置。

编辑了问题。Gac中提供的版本和web中列出的版本。配置是2。我现在使用的版本,我通过“浏览…”手动引用来自临时项目的是3。它运行!!1.正式版本在哪里?2.为什么会发生这种情况,即为什么我必须手动选择v3?3.我应该更改web.config中的内容吗?当我部署到真正的服务器(不是通过visual studio的IIS Express)时会发生什么?请更新您的答案,以便我可以接受。好的,我会尝试。同时,在我手动随机选择版本为3的System.Web.Razor.DLL文件后,一切都正常。在任何情况下,我都会将其标记为答案。我有完全相同的问题。我的nancy应用程序使用v3,但当我创建windows服务并将nancy依赖项安装到其中时它部署v2,Razor停止工作。