【发布时间】:2014-05-27 15:27:42
【问题描述】:
我的 Global.asax 文件如下所示:
<%@ Application Language="C#" %>
<%@ Import Namespace="WMED" %>
<%@ Import Namespace="System.Web.Optimization" %>
<%@ Import Namespace="System.Web.Routing" %>
<script runat="server">
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
BundleConfig.RegisterBundles(BundleTable.Bundles);
AuthConfig.RegisterOpenAuth();
RouteConfig.RegisterRoutes(RouteTable.Routes);
}
void Application_End(object sender, EventArgs e)
{
// Code that runs on application shutdown
}
void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
}
</script>
当我第一次运行我的网络应用程序时,我收到了以下错误:
Compiler Error Message: CS0433: The type 'WebSite5.BundleConfig' exists in both 'c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\dc09734f\e0cd1143\App_Code.f12uuiuu.dll' and 'c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\dc09734f\e0cd1143\assembly\dl3\f6c46402\e43f8fd6_b679cf01\WMEXEC.DLL'
Source Error:
Line 9: {
Line 10: // Code that runs on application startup
Line 11: BundleConfig.RegisterBundles(BundleTable.Bundles);
Line 12: AuthConfig.RegisterOpenAuth();
Line 13: RouteConfig.RegisterRoutes(RouteTable.Routes);
我将batch=false 添加到我的Web.config 文件并重新运行Web 应用程序,现在我收到以下错误:
Compiler Error Message: CS0103: The name 'AuthConfig' and 'RouteConfig' does not exist in the current context
Source Error:
Line 10: // Code that runs on application startup
Line 11: BundleConfig.RegisterBundles(BundleTable.Bundles);
Line 12: AuthConfig.RegisterOpenAuth();
Line 13: RouteConfig.RegisterRoutes(RouteTable.Routes);
Line 14: }
有问题的两个名称是位于我的 App_Code 文件夹中的 .CS 文件,但我不确定它为什么不起作用。
请帮我解决这个问题。
【问题讨论】:
-
可能是你导入了
WMED命名空间,能去掉吗? -
来自 Global.ASAX 文件?
-
是的,删除
<%@ Import Namespace="WMED" %>行。 -
我得到了所有三行的
CS0103: The name 'BundleConfig' does not exist in the current context。 -
你在上面说
When I first ran my web application I received the following error:,回到那个状态,然后删除WMED引用。