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

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

源错误:

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

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

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


当前回答

如果在全局变量之后更改名称空间信息(项目或类级别),有时会发生这种情况。生成Asax。

右键单击全局。asax文件,选择“打开”,然后选择“XML(文本)编辑器与编码”(其他编辑器也可以工作,但这是我使用的)。

然后编辑XML指令中的“Inherits”部分

<%MvcApplication" Language " ="C " %>)

以便它与应用程序类的实际全名相匹配。就是这样。

另一种选择是从Global.asax.cs中复制所有代码,然后删除并创建另一个Global。asax文件(然后将代码复制回Global.asax.cs)。

其他回答

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.

尝试修改全局变量。Asax文件(简单添加一个空格的地方),并重新运行。这将迫使内置的web服务器刷新和重新编译全局。asax文件。

也做一个清理和重建-应该修复问题

对于我来说,web组装是GAC的一部分……因此,在构建后,它需要安装在GAC和它工作。

您的本地web服务器运行的代码与您实际使用的代码不同。确保你已经停止调试,停止你的本地web服务器,按照Peter的建议清理和重建,仔细检查你的全局。Asax和global.asax.cs,再试一次。

如果这不起作用,并且您使用的是本地IIS,请尝试在IIS管理器中删除站点并手动重新创建它。

清空bin文件夹。构建所有依赖类库并在主项目中引用它们,然后构建完整的解决方案。