我得到了错误
无法加载类型mvcapapplication
当我试图运行我的网站时。
如何纠正?
我得到了错误
无法加载类型mvcapapplication
当我试图运行我的网站时。
如何纠正?
当前回答
我的解决方案是右键单击Mvc项目,选择属性,然后单击创建虚拟目录。
弹出一个消息框,说明项目被映射到错误的文件夹(它显示了不同TFS项目的文件夹。它提供了将其映射回正确文件夹的选项。
其他回答
检查global.asax中提供的信息背后的代码。它们应该正确地指向后面代码中的类。
示例global.asax:
<%@ Application Codebehind="Global.asax.cs" Inherits="MyApplicationNamespace.MyMvcApplication" Language="C#" %>
背后的示例代码:
namespace MyApplicationNamespace
{
public class MyMvcApplication : System.Web.HttpApplication
{
protected void Application_Start( )
{
AreaRegistration.RegisterAllAreas( );
FilterConfig.RegisterGlobalFilters( GlobalFilters.Filters );
RouteConfig.RegisterRoutes( RouteTable.Routes );
BundleConfig.RegisterBundles( BundleTable.Bundles );
}
}
}
在过去的十年里,我已经见过很多次了,现在又一次。有许多问题都会导致同样的错误。
一个原因是文件的重命名。如果您使用的是.cshtml文件,请检查这些文件和Views\web中的所有名称空间。配置文件。对于web表单,重命名为Default。Aspx(相关的.cs和设计器文件将自动重命名)。代码更改了,但是标记中的Inherits行没有更改。手动更改。仔细检查设计师页面。有时(VS2005-8?)设计器页面不反映名称空间的更改。2010年还没见过这种情况。
Another issue is when it all works in VS or on your local PC but not when you deploy. This could be because the deployment environment isn't structured the same. For example, the error occurs if you place your code in a virtual directory under an application folder, but it doesn't occur if you create a new application folder and place all of your files in there. I don't understand this one, as I've had the new child/virtual folder set with the same permissions (or so I think) and (I believe) the application pool should work the same for everything in a given application folder.
在我的例子中,我也有一个bin文件夹,其中包含从IIS服务器上的其他程序集更新的程序集。同样,确保这些文件在单独的应用程序文件夹中运行才会成功。
HTH
[摘自问题]
如果你得到这个错误:“无法加载类型MvcApplication”,查看你的项目的输出路径,并确保它被设置为“bin\”。问题是AspNetCompiler无法找到不在默认位置的文件。
更改输出文件夹的另一个副作用是,您将无法调试代码,并且会出现一条消息,说无法找到程序集信息。
在解决方案上手动构建即可。
如果您正在使用本地IIS,请尝试在IIS管理器中删除网站注册,然后手动重新创建。
我知道这个问题已经有很多解决方案了,但我想我只提一下为我解决的方法。
我的配置被设置为调试。把它改成Release对我来说很管用。