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

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

源错误:

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

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

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


当前回答

重新创建虚拟目录为我解决了这个问题。

(在此之前,我尝试了这里列出的其他建议,如清理解决方案,删除bin文件夹,重建解决方案等。没有一个工作,直到我重新创建虚拟目录)

Debug ->调试属性-> Web ->创建虚拟目录

其他回答

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

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

我的问题是我没有在我的项目中包含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);
        }
    }
}

如果你在同一个解决方案中运行Web和WebApi,如果你不小心忘记将VS解决方案设置为“多个启动项目”,也会发生这种情况。

您可以通过右键单击解决方案资源管理器中的解决方案并选择“属性”来检查这一点。然后寻找“创业项目”。

我不得不去BUILD ->配置管理器,然后——咳咳——勾选我的项目旁边的复选框,以确保它实际上得到了构建。

I faced the problem in VS 2017 out of no where, took my whole day going through 100 of solutions any of these didnt work. I then took my whole solution and started it on different machine having VS 2017 installation.. IT FINALLY WORKED. Than reinstalled VS 2017 on the original one and it started running on that too. I strongly recommend you try your solution on a different machine before wasting much time to debug it, bcz it is a BUG in VS 2017 as it seemed for me, have reported same to VS TEAM. Hope this helps any one in grief. Cheers.