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

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

源错误:

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

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

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


当前回答

我在一个非常古老的溶液中有这个。事实证明,真正的问题是这些项目构建到4.6.1,而不是其他被引用的dll构建到4.7.2。在将解决方案中的所有项目更改为4.7.2后,它成功构建并运行应用程序。

其他回答

您还可以在IIS中检查站点的属性。(在IIS中,右键单击站点,选择“属性”。)确保物理路径设置指向您的应用程序的正确路径,而不是其他应用程序。(这为我解决了这个错误。)

我遇到了这个错误消息,最终发现这个错误消息具有误导性。在我的情况下,似乎已经在IIS路由问题,导致全局。从web服务器上的另一个站点读取Asax,从而产生错误。

在IIS中,我的站点绑定到http:*80:webservices。包含一个名为MyAPI的应用程序。我在使用web服务器的ip地址调用MyAPI应用程序时收到了可怕的消息。

为了成功地调用我的应用程序,我必须为webservices添加一个主机文件条目。在所有调用MyAPI应用程序的机器上。然后,我的所有请求都必须以http://webservices.local/MyAPI/作为前缀,以便正确路由。

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

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应用程序中经历了这种情况。 问题是一个nuget包带来了一个依赖: Microsoft.Net.Compiler和Microsoft.Code.Dom

它们支持多级编译器版本。

这将我的应用程序转换为ASP。NET网站而不是Web应用程序..我花了很长时间才解决这个问题——2.5天!!

我从Nuget管理器中删除了这些文件,删除了obj和bin目录中的文件-关闭studio -然后重新打开并重建项目。这就解决了问题

那是多么痛苦啊!!

我希望我在这一点上节省了一些时间!