首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >无法加载文件或程序集“”System.Web.Razor“”或其依赖项之一

无法加载文件或程序集“”System.Web.Razor“”或其依赖项之一
EN

Stack Overflow用户
提问于 2013-04-08 16:18:00
回答 6查看 64.9K关注 0票数 25

我在我的网站(web应用程序)中使用了Umbraco 4.11.6,.My网站在本地主机上工作(从Visual studio 2012和IIS(V7)测试),但当我从互联网空间运行它时,我得到了一个错误。错误是:

未能加载文件或程序集“System.Web.Razor”或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配。(HRESULT异常: 0x80131040)

程序集加载跟踪:以下信息有助于确定无法加载程序集“System.Web.Razor”的原因。

警告:程序集绑定日志记录已关闭。若要启用程序集绑定失败日志记录,请将注册表值HKLM\Software\Microsoft\Fusion!EnableLog设置为1。注意:程序集绑定失败日志记录会带来一些性能损失。若要关闭此功能,请删除注册表值HKLM\Software\Microsoft\Fusion!EnableLog。

堆栈跟踪:

FileLoadException:未能加载文件或程序集“System.Web.Razor”或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配。(HRESULT异常: 0x80131040) FileLoadException:无法加载文件或程序集“”System.Web.Razor,Version=2.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35“”或其依赖项之一。“”找到的程序集的清单定义与程序集引用不匹配。(HRESULT异常: 0x80131040) System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName,字符串codeBase,证据assemblySecurity,RuntimeAssembly locationHint,StackCrawlMark& stackMark,IntPtr pPrivHostBinder,Boolean throwOnFileNotFound,Boolean forIntrospection,Boolean suppressSecurityChecks) +0

System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef,证据assemblySecurity,RuntimeAssembly reqAssembly,StackCrawlMark& stackMark,IntPtr pPrivHostBinder,Boolean throwOnFileNotFound,Boolean forIntrospection,Boolean suppressSecurityChecks) +210

System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,Evidence,StackCrawlMark& stackMark,IntPtr pPrivHostBinder,Boolean forIntrospection) +242

System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,Evidence,StackCrawlMark& stackMark,Boolean forIntrospection) +17 System.Reflection.Assembly.Load(String assemblyString) +35

System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName,布尔型starDirective) +122

ConfigurationErrorsException:未能加载文件或程序集'System.Web.Razor,Version=2.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35‘或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配。(HRESULT异常: 0x80131040)

System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName,布尔型starDirective) +12761078

System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +503 System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +142 System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +334

System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath) +203

System.Web.Compilation.BuildManager.ExecutePreAppStart() +152

System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager、IApplicationHost appHost、IConfigMapPathFactory configMapPathFactory、HostingEnvironmentParameters hostingParameters、policyLevel PolicyLevel、Exception appDomainCreationException) +1151

HttpException (0x80004005):未能加载文件或程序集'System.Web.Razor,Version=2.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35‘或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配。(HRESULT异常: 0x80131040)

System.Web.HttpRuntime.FirstRequestInit(HttpContext上下文) +12881540 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext上下文) +159 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr,HttpContext上下文) +12722601

版本信息:微软.NET框架版本:4.0.30319;ASP.NET版本:4.0.30319.17929

WebConfig的一部分:

代码语言:javascript
复制
<runtime>
<!-- Old asp.net ajax assembly bindings -->
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="4.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="4.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
  </dependentAssembly>
</assemblyBinding>

EN

回答 6

Stack Overflow用户

回答已采纳

发布于 2013-04-09 04:06:45

解决这个问题的方法有很多:

  1. 在web服务器上安装MVC (这并不总是可能的)。在
  2. 中,你可以设置dll在构建时复制到本地,请参阅下面的文章(请注意MVC dll稍微更改了一些名称,但它给了你这个过程)将适当的dll从你的GAC中复制到
  3. 站点的bin文件夹中。为此,在资源管理器中打开"%windir%\Microsoft.NET\assembly\GAC_MSIL“,您将发现所有安装在GAC中的all,您可以将适当的版本复制到您的项目中。这与上面的方法类似,但绕过了构建项目。

就文件而言,您可能需要的不仅仅是System.Web.Razor.dll,但是这将适用于所有丢失的文件。

票数 18
EN

Stack Overflow用户

发布于 2018-01-03 22:36:16

重新安装Microsoft.AspNet.Razor包,如ADreNaLiNe-DJ posted。最好的方法是使用Update-Package命令,因为Install-Package命令不提供强制重新安装的选项,请参见docs

代码语言:javascript
复制
PM> Update-Package Microsoft.AspNet.Razor -reinstall
票数 14
EN

Stack Overflow用户

发布于 2016-06-09 14:33:56

这些解决方案都没有帮到我:要么是因为我不能在服务器上安装任何东西,要么是因为我不喜欢在不使用Nuget的情况下直接包含dll。

我使用的解决方案是安装/重新安装名为的nuget包

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15874366

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档