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

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

源错误:

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

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

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


当前回答

我用很简单的方法修好了它。你所要做的就是删除ProjectName\bin文件夹中的所有文件,然后从Visual studio顶部菜单栏Build->Rebuild Solution再次重建项目,你就完成了。现在试着运行这个项目。这个过程在Visual Studio 2022中为我工作。

其他回答

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目录,删除目录的内容,而不是目录本身。否则,可能会导致权限丢失。

我发现在项目中更改命名空间,而没有在整个解决方案中重构它是我的问题。检查你的项目属性,看看你的命名空间是什么,确保排列整齐,全面。

我正在开发一个旧的“基于文件夹的”ASP。NET web项目(我讨厌)-并发现这是我的修复:

创建一个App_Code文件夹(如果你还没有的话)

将Global.asax.vb文件移动到App_Code文件夹中

全局中的标记。Asax可以省略任何名称空间(至少对于这种类型的项目):

<%@ Application Codebehind="Global.asax.vb" Inherits="MyApp" Language="VB" %>

…其中“MyApp”是在Global.asax.vb中定义的类的名称

我也得到了同样的错误…检查您的虚拟目录的IIS配置,并确保属性- ASP。Net - asp。NET版本与项目属性-应用程序-目标框架相同。(这为我解决了这个错误。)

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

基本上,我的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会让你完全构建和运行包含这个问题的解决方案,这很令人恼火。这是自找麻烦!