指数数组的边界之外

指数数组的边界之外

本文介绍了StyleBundle指数数组的边界之外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想包括在目录中的所有文件是这样的:

  bundles.Add(新StyleBundle(〜/内容/ simpliq_css)。包括(
    〜/内容/ simpliq / *。CSS
));

但我得到这个错误指数数组的边界之外

和红线是:

@ Styles.Render(〜/内容/ simpliq_css)

  [IndexOutOfRangeException:索引是该数组的边界之外]
   System.String.get_Chars(的Int32指数)+ 0
   Microsoft.Ajax.Utilities.CssParser.Append(obj对象,TokenType tokenType)+402
   Microsoft.Ajax.Utilities.CssParser.AppendCurrent()+74
   Microsoft.Ajax.Utilities.CssParser.ParseElementName()+321
   Microsoft.Ajax.Utilities.CssParser.ParseSimpleSelector()+54
   Microsoft.Ajax.Utilities.CssParser.ParseSelector()555
   Microsoft.Ajax.Utilities.CssParser.ParseRule()+ 165
   Microsoft.Ajax.Utilities.CssParser.ParseStylesheet()+186
   Microsoft.Ajax.Utilities.CssParser.Parse(字符串源)946
   Microsoft.Ajax.Utilities.Minifier.MinifyStyleSheet(字符串源,CssSettings设置,codeSettings scriptSettings)439
   Microsoft.Ajax.Utilities.Minifier.MinifyStyleSheet(字符串源,CssSettings设置)+73
   System.Web.Optimization.CssMinify.Process(BundleContext的背景下,BundleResponse响应)+302
   System.Web.Optimization.Bundle.ApplyTransforms(BundleContext的背景下,字符串bundleContent,IEnumerable`1 bundleFiles)+207
   System.Web.Optimization.Bundle.GenerateBundleResponse(BundleContext的上下文)+355
   System.Web.Optimization.Bundle.GetBundleResponse(BundleContext的上下文)+104
   System.Web.Optimization.BundleResolver.GetBundleContents(字符串virtualPath)+254
   System.Web.Optimization.AssetManager.EliminateDuplicatesAndResolveUrls(IEnumerable`1裁判)435
   System.Web.Optimization.AssetManager.DeterminePathsToRender(IEnumerable`1资产)1030
   System.Web.Optimization.AssetManager.RenderExplicit(字符串tagFormat,字符串[]路径)+75
   System.Web.Optimization.Styles.RenderFormat(字符串tagFormat,字符串[]路径)293
   System.Web.Optimization.Styles.Render(字符串[]路径)+51
   ASP._Page_Areas_Admin_Views_Shared__Layout_cshtml.Execute()在F:\\ MyProjects下\\寓言\\寓言\\ Fables.Web \\区\\管理\\查看\\共享\\ _Layout.cshtml:8
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy()+271
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy()+ 120
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext的pageContext,TextWriter的作家,WebPageRenderingBase起始页)+145
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext的pageContext,TextWriter的作家)+41
   System.Web.WebPages<> c__DisplayClass7< RenderPageCore> b__6(TextWriter的作家)335
   System.Web.WebPages.HelperResult.WriteTo(TextWriter的作家)+42
   System.Web.WebPages.WebPageExecutingBase.WriteTo(TextWriter的作家,HelperResult内容)+45
   System.Web.WebPages.WebPageBase.Write(HelperResult结果)+53
   System.Web.WebPages.WebPageBase.RenderSurrounding(字符串partialViewName,Action`1体)+178
   System.Web.WebPages.WebPageBase.PopContext()347
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext的pageContext,TextWriter的作家,WebPageRenderingBase起始页)+154
   System.Web.Mvc.RazorView.RenderView(ViewContext viewContext,TextWriter的作家,对象实例)695
   System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext,TextWriter的作家)+382
   System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext上下文)431
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext,ActionResult的的ActionResult)+39
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1过滤器,的Int32 filterIndex,ResultExecutingContext preContext,ControllerContext controllerContext,ActionResult的的ActionResult)+116
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1过滤器,的Int32 filterIndex,ResultExecutingContext preContext,ControllerContext controllerContext,ActionResult的的ActionResult)529
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext,IList`1过滤器,的ActionResult的ActionResult)+106
   System.Web.Mvc.Async<方式>&c__DisplayClass28 LT; BeginInvokeAction> b__19()+321
   System.Web.Mvc.Async<方式>&c__DisplayClass1e LT; BeginInvokeAction> b__1b(IAsyncResult的asyncResult)+185
   System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult的asyncResult)+42
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End()+133
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult的asyncResult,对象标记)+56
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult的asyncResult)+ 40
   System.Web.Mvc.Controller< BeginExecuteCore> b__1d(IAsyncResult的asyncResult,ExecuteCoreState innerState)+34
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult的asyncResult)+ 70
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End()+139
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult的asyncResult,对象标记)+59
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult的asyncResult,对象标记)+ 40
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult的asyncResult)+44
   System.Web.Mvc.Controller< BeginExecute> b__15(IAsyncResult的asyncResult,控制器控制器)+39
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult的asyncResult)+62
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End()+139
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult的asyncResult,对象标记)+59
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult的asyncResult,对象标记)+ 40
   System.Web.Mvc.Controller.EndExecute(IAsyncResult的asyncResult)+39
   System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult的asyncResult)+39
   System.Web.Mvc.MvcHandler< BeginProcessRequest> b__4(IAsyncResult的asyncResult,ProcessRequestState innerState)+39
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult的asyncResult)+ 70
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End()+139
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult的asyncResult,对象标记)+59
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult的asyncResult,对象标记)+ 40
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult的asyncResult)+ 40
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult的结果)+38
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()9514928
   System.Web.HttpApplication.ExecuteStep(IExecutionStep一步,布尔和放大器; completedSynchronously)+155


解决方案

问题是下一包的版本:

您需要更新它,问题会得到解决。

I want to include all files in directory like this:

bundles.Add(new StyleBundle("~/Content/simpliq_css").Include(
    "~/Content/simpliq/*.css"
));

But i got this error Index was outside the bounds of the array

and red line is:

@Styles.Render("~/Content/simpliq_css")

[IndexOutOfRangeException: Index was outside the bounds of the array.]
   System.String.get_Chars(Int32 index) +0
   Microsoft.Ajax.Utilities.CssParser.Append(Object obj, TokenType tokenType) +402
   Microsoft.Ajax.Utilities.CssParser.AppendCurrent() +74
   Microsoft.Ajax.Utilities.CssParser.ParseElementName() +321
   Microsoft.Ajax.Utilities.CssParser.ParseSimpleSelector() +54
   Microsoft.Ajax.Utilities.CssParser.ParseSelector() +555
   Microsoft.Ajax.Utilities.CssParser.ParseRule() +165
   Microsoft.Ajax.Utilities.CssParser.ParseStylesheet() +186
   Microsoft.Ajax.Utilities.CssParser.Parse(String source) +946
   Microsoft.Ajax.Utilities.Minifier.MinifyStyleSheet(String source, CssSettings settings, CodeSettings scriptSettings) +439
   Microsoft.Ajax.Utilities.Minifier.MinifyStyleSheet(String source, CssSettings settings) +73
   System.Web.Optimization.CssMinify.Process(BundleContext context, BundleResponse response) +302
   System.Web.Optimization.Bundle.ApplyTransforms(BundleContext context, String bundleContent, IEnumerable`1 bundleFiles) +207
   System.Web.Optimization.Bundle.GenerateBundleResponse(BundleContext context) +355
   System.Web.Optimization.Bundle.GetBundleResponse(BundleContext context) +104
   System.Web.Optimization.BundleResolver.GetBundleContents(String virtualPath) +254
   System.Web.Optimization.AssetManager.EliminateDuplicatesAndResolveUrls(IEnumerable`1 refs) +435
   System.Web.Optimization.AssetManager.DeterminePathsToRender(IEnumerable`1 assets) +1030
   System.Web.Optimization.AssetManager.RenderExplicit(String tagFormat, String[] paths) +75
   System.Web.Optimization.Styles.RenderFormat(String tagFormat, String[] paths) +293
   System.Web.Optimization.Styles.Render(String[] paths) +51
   ASP._Page_Areas_Admin_Views_Shared__Layout_cshtml.Execute() in f:\MyProjects\Fables\Fables\Fables.Web\Areas\Admin\Views\Shared\_Layout.cshtml:8
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +271
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +120
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +145
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer) +41
   System.Web.WebPages.<>c__DisplayClass7.<RenderPageCore>b__6(TextWriter writer) +335
   System.Web.WebPages.HelperResult.WriteTo(TextWriter writer) +42
   System.Web.WebPages.WebPageExecutingBase.WriteTo(TextWriter writer, HelperResult content) +45
   System.Web.WebPages.WebPageBase.Write(HelperResult result) +53
   System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action`1 body) +178
   System.Web.WebPages.WebPageBase.PopContext() +347
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +154
   System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +695
   System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +382
   System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +431
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +39
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +116
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +529
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +106
   System.Web.Mvc.Async.<>c__DisplayClass28.<BeginInvokeAction>b__19() +321
   System.Web.Mvc.Async.<>c__DisplayClass1e.<BeginInvokeAction>b__1b(IAsyncResult asyncResult) +185
   System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +42
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +133
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +56
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +40
   System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +34
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +70
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +44
   System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +39
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +62
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +39
   System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +39
   System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__4(IAsyncResult asyncResult, ProcessRequestState innerState) +39
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +70
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +40
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +38
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9514928
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
解决方案

Problem was in version of next packages:

You have to update it and problem will be solved.

这篇关于StyleBundle指数数组的边界之外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 15:53