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

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

源错误:

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

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

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


当前回答

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

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

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

其他回答

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.

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

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

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

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

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

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

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

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