Problem with a Release build of my ASP.NET MVC app

174 views
Skip to first unread message

Derrick Morin

unread,
Nov 21, 2019, 3:23:34 PM11/21/19
to SquishIt
Hi,

I just grabbed version 1.0.2 from Nuget and I am have a problem with a Release build of my ASP.NET MVC app.

when I set debug="true" in Web.Config and I put the CssBundle render in the <head> of a Razor view it works as expected.

from web.config
<compilation defaultLanguage="c#" targetFramework="4.7.2" debug="true"/>  

from razor view
    @MvcHtmlString.Create(Bundle.Css()
        .Add("styles.css")
        .Render("styles.min.css")
        )

it renders like this 
<link rel="stylesheet" type="text/css" href="styles.css" />


when I change debug="false" in web.config I get the following exception.

Am I missing something?


Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 43:     @MvcHtmlString.Create(Bundle.Css()
Line 44:         .Add("styles.css")
Line 45:         .Render("styles.min.css")

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
   SquishIt.Framework.Files.FileReaderFactory.GetFileReader(String file) in C:\Users\AlexUllrich\git\SquishIt\SquishIt.Framework\Files\FileReaderFactory.cs:18
   SquishIt.Framework.Base.BundleBase`1.ReadFile(String file) in C:\Users\AlexUllrich\git\SquishIt\SquishIt.Framework\Base\BundleBase.Rendering.Internals.cs:87
   SquishIt.Framework.CSS.CSSBundle.ProcessCssFile(String file, String outputFile, String fileForCssRewriter, Boolean asImport) in C:\Users\AlexUllrich\git\SquishIt\SquishIt.Framework\CSS\CSSBundle.cs:140
   SquishIt.Framework.CSS.CSSBundle.ProcessFile(String file, String outputFile, Asset originalAsset) in C:\Users\AlexUllrich\git\SquishIt\SquishIt.Framework\CSS\CSSBundle.cs:133
   System.Linq.WhereSelectArrayIterator`2.MoveNext() +77
   System.Linq.<SelectManyIterator>d__17`2.MoveNext() +629
   System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +452
   System.Linq.Enumerable.ToList(IEnumerable`1 source) +72
   SquishIt.Framework.CSS.CSSBundle.AggregateContent(List`1 assets, StringBuilder sb, String outputFile) in C:\Users\AlexUllrich\git\SquishIt\SquishIt.Framework\CSS\CSSBundle.cs:117
   SquishIt.Framework.Base.BundleBase`1.GetMinifiedContent(List`1 assets, String outputFile) in C:\Users\AlexUllrich\git\SquishIt\SquishIt.Framework\Base\BundleBase.Rendering.Internals.cs:318
   SquishIt.Framework.Base.BundleBase`1.RenderRelease(String key, String renderTo, IRenderer renderer) in C:\Users\AlexUllrich\git\SquishIt\SquishIt.Framework\Base\BundleBase.Rendering.Internals.cs:275
   ASP._Page_Views_Home_Index_cshtml.Execute() in c:\E\lhotse\Views\Home\Index.cshtml:43
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +251
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +147
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +106
   System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +377
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +90
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +795
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +81
   System.Web.Mvc.Async.<>c__DisplayClass3_1.<BeginInvokeAction>b__1(IAsyncResult asyncResult) +188
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +38
   System.Web.Mvc.<>c.<BeginExecuteCore>b__152_1(IAsyncResult asyncResult, ExecuteCoreState innerState) +29
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +73
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +52
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +39
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +38
   System.Web.Mvc.<>c.<BeginProcessRequest>b__20_1(IAsyncResult asyncResult, ProcessRequestState innerState) +43
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +73
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +38
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +431
   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +75
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +158


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4001.0



Derrick Morin

unread,
Nov 21, 2019, 5:09:14 PM11/21/19
to SquishIt
I reverted back to 1.0.1 and it works as expected.

Alex Ullrich

unread,
Nov 22, 2019, 7:08:20 AM11/22/19
to SquishIt
Thanks for letting me know looks like I fat-fingered something in latest release.  Just pushed 1.0.3 it should work for you unless you are in an environment where you need to favor MD5 over SHA hashing for some reason.

Thanks,

Alex
Reply all
Reply to author
Forward
0 new messages