我得到了错误

无法加载类型mvcapapplication

当我试图运行我的网站时。

如何纠正?


当前回答

我得到这个错误是因为我正在运行项目,尽管有一些编译时错误。这一点我没有注意到。

其他回答

我知道这个问题已经有很多解决方案了,但我想我只提一下为我解决的方法。

我的配置被设置为调试。把它改成Release对我来说很管用。

In some circumstances, new projects you create are not by default set to build. If you right-click on your solution, choose Properties, and choose the Configuration Properties | Configuration node on the left and ensure your project has a checkmark under the Build column. In normal circumstances I've found this happens by default. In other circumstances (I happen to have a somewhat complex Web Api / Xamarin Android and iOS / Mvc 5 solution that exhibits this behavior) the checkmark isn't present.

这与其他答案相关——如果你的web项目的程序集不可用,你会得到这个错误。但这可能是一个常见的场景,特别是因为您实际上编译了您的解决方案——项目只是没有得到构建。

确保global.asax.cs中的命名空间与你的webapp的命名空间匹配

我得到这个错误是因为我正在运行项目,尽管有一些编译时错误。这一点我没有注意到。

在我的情况下,问题是我重命名类全局到MvcApplication。当重命名时,它必须在所有地方进行更改,否则应用程序将在给定的命名空间中寻找全局类。