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

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

源错误:

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

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

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


当前回答

我最近在一个Web应用程序中经历了这种情况。 问题是一个nuget包带来了一个依赖: Microsoft.Net.Compiler和Microsoft.Code.Dom

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

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

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

那是多么痛苦啊!!

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

其他回答

我的问题是我没有在我的项目中包含global.asax.cs。因为我是从。net 4.5复制文件到4.0,所以我没有注释掉4.0中不需要的行。因为它不包括visual studio编译它无论如何没有问题。但是当我加入它时,它突出显示了导致问题的行。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
//using System.Web.Http;
using System.Web.Mvc;
//using System.Web.Optimization;
using System.Web.Routing;

namespace YourNameSpace
{
    public class WebApiApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            //GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            //BundleConfig.RegisterBundles(BundleTable.Bundles);
        }
    }
}

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.

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

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

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

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

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

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

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

这个问题,我解决了给文件夹的正确权限,以及从IIS检查。

当我在本地环境中测试时,我得到了每个人的许可。但是在发布模式下,我认为我们只允许ASP。网用户。