我在一个MVC3项目上工作,收到以下错误:

解析器错误信息:无法加载类型“GodsCreationTaxidermy.MvcApplication”。

源错误:

第1行:<%@ Application Codebehind="Global.asax.cs" Inherits="GodsCreationTaxidermy.Core. core . "MvcApplication" Language=" c# " %>

我得到的错误是无法加载GodsCreationTaxidermy.Core.MvcApplication,但在这个屏幕截图中,核心部分没有显示在错误中:

有人对这个错误有什么想法或解决方案吗?


当前回答

我今天遇到了这个问题,我花了一段时间才找到原因。

基本上,我的VS2015主项目包括一个使用更高版本的. net Framework构建的子项目。

奇怪的是,当你遇到这个问题时,VS2015会很高兴地报告解决方案已经构建好了,但当你尝试运行网站时,它只是给你一个误导性的错误,表明你的Global.asax.cs文件是错误的。

因此,如果您看到这个错误,并且清理/重建不起作用,打开项目的引用树,并检查感叹号。

同样,检查你的输出窗口是否有这样的消息:

The primary reference "C:\Projects\Business Objects 4\bin\Release\BusinessObjects.dll" 
could not be resolved because it was built against 
the ".NETFramework,Version=v4.5" framework. 
This is a higher version than the currently targeted framework
".NETFramework,Version=v4.0".

当然,解决方案是右键单击您的主项目,选择顶部选项卡“Application”,并将目标框架版本更改为与您的子项目匹配的更高版本。

Visual Studio 2015会让你完全构建和运行包含这个问题的解决方案,这很令人恼火。这是自找麻烦!

其他回答

我试过这里的所有方法,但都没用。我的项目是在VS 2013。我已经升级到VS 2015,并在2015年创建了我所有的新应用程序,但加载、编译、构建等所有在2013年构建的旧应用程序。

我最终在2015年加载了解决方案,它为我解决了这个问题。

I faced the problem in VS 2017 out of no where, took my whole day going through 100 of solutions any of these didnt work. I then took my whole solution and started it on different machine having VS 2017 installation.. IT FINALLY WORKED. Than reinstalled VS 2017 on the original one and it started running on that too. I strongly recommend you try your solution on a different machine before wasting much time to debug it, bcz it is a BUG in VS 2017 as it seemed for me, have reported same to VS TEAM. Hope this helps any one in grief. Cheers.

我只是在一个MVC5应用程序上遇到了这个问题,没有什么对我有用。这发生在我试图将SVN还原到项目的旧版本之后。

我必须删除Global. asax.cs,然后通过右键单击项目->添加新项目-> Global来添加一个新的项目。asax和THAT最终解决了它。

只是觉得也许能帮到别人。

Yes, I read all the answers. However, if you are me and have been pulling out all of what's left of your hair, then try checking the \bin folder. Like most proj files might have several configurations grouped under the XML element PropertyGroup, then I changed the OutputPath value from 'bin\Debug' to remove the '\Debug' part and Rebuild. This placed the files in the \bin folder allowing the Express IIS to find and load the build. I am left wondering what is the correct way to manage these different builds so that a local debug deploy is able to find and load the target environment.

我花了好几天时间研究这个问题。我最终通过以下这篇文章中的建议解决了这个问题。

将平台目标更改为任意CPU。我目前没有这个配置,所以我必须去配置管理器并添加它。我专门为x64编译。仅凭这一点并不能解决错误。 将输出路径更改为bin\而不是bin\x64\Debug。在我改变平台目标之前,我已经尝试过几次了。它只会得到一个错误,因为格式无效而无法加载程序集。

要明确的是,在它开始工作之前,我必须做这两件事。我已经尝试了多次,但它从来没有解决,直到我做了两个。

如果我将这些设置中的任何一个更改回原来的设置,我将再次得到相同的错误,尽管已经运行了Clean Solution,并手动删除了bin目录中的所有内容。