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

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

源错误:

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

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

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


当前回答

TL;DR:对我来说,在尝试了3天我能在这里找到的所有其他答案之后,最终的解决方案是在我的IIS应用程序池高级设置中将启用32位应用程序设置为True,然后重新创建临时ASP。并为我的IIS_IUSRS组增加“修改”和“写入”权限。

我尝试的步骤:

Completely clean and rebuild solution. Shut down and restart Visual Studio. Delete Temporary ASP.NET Files directories (C:\Windows\Microsoft.NET\Framework*). This is where my problems really started: I deleted too much. Reboot development machine. Remove .vs folder and rebuild solution. Recreate C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files. My projects are 64-bit applications, even though build platform is AnyCPU. Verify output directory was set to bin/ on web projects. Wipe out and check out a clean copy of my version control branch. Wipe out and clone a fresh copy of my version control repository. Run Windows update to latest versions of .NET Frameworks. Repair, uninstall, and reinstall .NET Frameworks 3.5 and 4.8. Uninstall and reinstall Visual Studio 2019 Professional. Uninstall and reinstall the Internet Information Services feature in Windows. Downgrade ASP.NET NuGet package and rebuild solution (issued reference errors due to changes in assemblies). Upgrade ASP.NET back to what my projects were using and rebuild solution. Recreate IIS virtual directory through web project's Web properties. Created "empty" Global.asax files. Restore my files after no change. Replace Codebehind="Global.asax.cs" with Codefile="Global.asax.cs". This started showing me load errors for references to assemblies that actually existed in the system. Enable 32-bit applications in IIS application pool. This started displaying an access error to a 32-bit temporary directory. Restore permissions to all Temporary ASP.NET Files directories (add all but Full Control). This finally got my web application working again.

我能够从网上找到的无数答案中拼凑出足够的信息。在搜索iis找不到引用的。net dll后找到了这个答案,我尝试了最后的几个步骤,让我再次工作,在我的第四天开始与这个令人难以置信的模糊问题作斗争。

如果有办法诊断出为什么全球。asax无法加载,而不是太通用的无法加载类型错误,没有详细信息。

这个故事的寓意:当清理临时ASP。NET Files目录,删除目录的内容,而不是目录本身。否则,可能会导致权限丢失。

其他回答

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

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

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

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

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

TL;DR:对我来说,在尝试了3天我能在这里找到的所有其他答案之后,最终的解决方案是在我的IIS应用程序池高级设置中将启用32位应用程序设置为True,然后重新创建临时ASP。并为我的IIS_IUSRS组增加“修改”和“写入”权限。

我尝试的步骤:

Completely clean and rebuild solution. Shut down and restart Visual Studio. Delete Temporary ASP.NET Files directories (C:\Windows\Microsoft.NET\Framework*). This is where my problems really started: I deleted too much. Reboot development machine. Remove .vs folder and rebuild solution. Recreate C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files. My projects are 64-bit applications, even though build platform is AnyCPU. Verify output directory was set to bin/ on web projects. Wipe out and check out a clean copy of my version control branch. Wipe out and clone a fresh copy of my version control repository. Run Windows update to latest versions of .NET Frameworks. Repair, uninstall, and reinstall .NET Frameworks 3.5 and 4.8. Uninstall and reinstall Visual Studio 2019 Professional. Uninstall and reinstall the Internet Information Services feature in Windows. Downgrade ASP.NET NuGet package and rebuild solution (issued reference errors due to changes in assemblies). Upgrade ASP.NET back to what my projects were using and rebuild solution. Recreate IIS virtual directory through web project's Web properties. Created "empty" Global.asax files. Restore my files after no change. Replace Codebehind="Global.asax.cs" with Codefile="Global.asax.cs". This started showing me load errors for references to assemblies that actually existed in the system. Enable 32-bit applications in IIS application pool. This started displaying an access error to a 32-bit temporary directory. Restore permissions to all Temporary ASP.NET Files directories (add all but Full Control). This finally got my web application working again.

我能够从网上找到的无数答案中拼凑出足够的信息。在搜索iis找不到引用的。net dll后找到了这个答案,我尝试了最后的几个步骤,让我再次工作,在我的第四天开始与这个令人难以置信的模糊问题作斗争。

如果有办法诊断出为什么全球。asax无法加载,而不是太通用的无法加载类型错误,没有详细信息。

这个故事的寓意:当清理临时ASP。NET Files目录,删除目录的内容,而不是目录本身。否则,可能会导致权限丢失。

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

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

我有同样的问题,当我有2个实例的Visual Studio运行相同的项目。所以我关闭了两个Visual Studio,只打开了一个实例,它现在工作得很好!