asp.net-mvc - 不应加载引用程序集来执行

标签 asp.net-mvc visual-studio

当我尝试在 Visual Studio 中调试它时,我的网站突然抛出此错误消息。如果我部署该网站,它就可以正常工作,不会出现任何错误。

解决此错误的任何建议。

[ConfigurationErrorsException: Could not load file or assembly 'Microsoft.Win32.Primitives' or one of its dependencies. Reference assemblies should not be loaded for execution.  They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +738
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +217
   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170
   System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +92
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +290
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +157
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +531

[HttpException (0x80004005): Could not load file or assembly 'Microsoft.Win32.Primitives' or one of its dependencies. Reference assemblies should not be loaded for execution.  They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9946132
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +90
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +261

最佳答案

尝试从 web.config 中删除该部分

<dependentAssembly>
    <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
</dependentAssembly>

关于asp.net-mvc - 不应加载引用程序集来执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40207137/

相关文章:

javascript - 如何将日期选择器的日历设置为始终可见,而且还能够获取所选日期?

visual-studio - Visual Studio C# 代码颜色

c# - Automapper 中缺少类型映射配置或不支持的映射错误

javascript - Viewbag For Dropdown For - 一旦操作具有参数,就会删除选定的属性

sql-server - 使用 SQL CLR 的 VS2013 数据库项目 - 对对象 [服务器名\用户名](数据库所有者)的未解析引用

c++ - 如何在 C++ 中调用 KeBugCheck 或 KeBugCheckEx

javascript - 在 Visual Studio 下编译时找不到模块

c# - 未知的 NuGet 错误无法检索信息

c# - 使用 mvcmailer 发送多封电子邮件

jquery - 简单的 ASP.NET MVC CRUD View 在 JavaScript UI 对话框中打开/关闭