我的MVC网站在启动时出现了BundleConfig
类中的运行时错误
,具体标题如下:
“System.NullReferenceException”类型的异常在 mscorlib.dll 中发生,但未在用户代码中处理
引用:
using System.Web.Optimization;
using BundleTransformer.Core.Bundles;
using BundleTransformer.Core.Orderers;
using BundleTransformer.Core.Transformers;
堆栈跟踪:
[NullReferenceException: Object reference not set to an instance of an object.]
BundleTransformer.Core.BundleTransformerContext..ctor() +162
BundleTransformer.Core.BundleTransformerContext.<.cctor>b__0() +44
System.Lazy`1.CreateValue() +416
System.Lazy`1.LazyInitValue() +152
System.Lazy`1.get_Value() +75
BundleTransformer.Core.BundleTransformerContext.get_Current() +60
BundleTransformer.Core.Transformers.CssTransformer..ctor(IMinifier minifier, IList`1 translators, IList`1 postProcessors, String[] ignorePatterns) +79
BundleTransformer.Core.Transformers.CssTransformer..ctor() +97
NWebsite.BundleConfig.RegisterBundles(BundleCollection bundles) in d:\Documents\Visual Studio 2013\Projects\N\Web\N.Website\App_Start\BundleConfig.cs:18
NWebsite.MvcApplication.Application_Start() in d:\Documents\Visual Studio 2013\Projects\N\Web\N.Website\Global.asax.cs:20
[HttpException (0x80004005): Object reference not set to an instance of an object.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +9916613
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +118
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296
[HttpException (0x80004005): Object reference not set to an instance of an object.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9930508
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
在 Global.asax 文件中的 MvcApplication 类:
public class MvcApplication : 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);
}
}
什么是它的原因,我该如何解决?
(针对 IT 技术问题的常见提问)