Replies: 3 comments
-
Replacing You'll need to find out what exactly does it minify incorrectly. It might be something we can change though. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your response. None of the scripts output by RenderScript() are minified (it's a debug build). Is jsMinify still a player in that case? Used dozens of third-party scripts in MVC over the last 10 years, first time I've ever seen this. Have no idea how'd I'd go about debugging it. |
Beta Was this translation helpful? Give feedback.
-
Similar in SO: https://stackoverflow.com/questions/30219807/object-reference-not-set-to-an-instance-of-an-object-in-layout-cshtml-after-upd (where I got the idea to try Bundle instead of ScriptBundle) (Converted to discussion, as this is not really a bug in Chart.js.) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Expected Behavior
Should be able to use the MVC 5 template for Framework 4.8, and bundle the chart.js script as with any other.
Current Behavior
Compiles fine, but Scripts.Render() for chart.js bundle throws when attempting to display a view:
System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=WebGrease
StackTrace:
at Microsoft.Ajax.Utilities.JSParser.ParseObjectLiteralProperty(Boolean isBindingPattern)
at Microsoft.Ajax.Utilities.JSParser.ParseObjectLiteral(Boolean isBindingPattern)
at Microsoft.Ajax.Utilities.JSParser.ParseLeftHandSideExpression(Boolean isMinus)
at Microsoft.Ajax.Utilities.JSParser.ParseUnaryExpression(Boolean& isLeftHandSideExpr, Boolean isMinus)
at Microsoft.Ajax.Utilities.JSParser.ParseExpression(Boolean single, JSToken inToken)
at Microsoft.Ajax.Utilities.JSParser.ParseExpressionList(JSToken terminator)
at Microsoft.Ajax.Utilities.JSParser.ParseMemberExpression(AstNode expression, List
1 newContexts) at Microsoft.Ajax.Utilities.JSParser.ParseLeftHandSideExpression(Boolean isMinus) at Microsoft.Ajax.Utilities.JSParser.ParseUnaryExpression(Boolean& isLeftHandSideExpr, Boolean isMinus) at Microsoft.Ajax.Utilities.JSParser.ParseExpression(Boolean single, JSToken inToken) at Microsoft.Ajax.Utilities.JSParser.ParseReturnStatement() at Microsoft.Ajax.Utilities.JSParser.ParseStatement(Boolean fSourceElement, Boolean skipImportantComment) at Microsoft.Ajax.Utilities.JSParser.ParseStatements(Block block) at Microsoft.Ajax.Utilities.JSParser.InternalParse() at Microsoft.Ajax.Utilities.JSParser.Parse(DocumentContext sourceContext) at Microsoft.Ajax.Utilities.JSParser.Parse(DocumentContext sourceContext, CodeSettings settings) at Microsoft.Ajax.Utilities.Minifier.MinifyJavaScript(String source, CodeSettings codeSettings) at System.Web.Optimization.JsMinify.Process(BundleContext context, BundleResponse response) at System.Web.Optimization.Bundle.ApplyTransforms(BundleContext context, String bundleContent, IEnumerable
1 bundleFiles)at System.Web.Optimization.Bundle.GenerateBundleResponse(BundleContext context)
at System.Web.Optimization.Bundle.GetBundleResponse(BundleContext context)
at System.Web.Optimization.BundleResolver.GetBundleContents(String virtualPath)
at System.Web.Optimization.AssetManager.DeterminePathsToRender(IEnumerable`1 assets)
at System.Web.Optimization.AssetManager.RenderExplicit(String tagFormat, String[] paths)
at System.Web.Optimization.Scripts.RenderFormat(String tagFormat, String[] paths)
at System.Web.Optimization.Scripts.Render(String[] paths)
at ASP._Page_Views_Shared__Layout_cshtml.Execute() in C:\Development\Projects\ChartIssue\ChartIssue\Views\Shared_Layout.cshtml:line 40
This exception was originally thrown at this call stack:
Microsoft.Ajax.Utilities.JSParser.ParseObjectLiteralProperty(bool)
Microsoft.Ajax.Utilities.JSParser.ParseObjectLiteral(bool)
Microsoft.Ajax.Utilities.JSParser.ParseLeftHandSideExpression(bool)
Microsoft.Ajax.Utilities.JSParser.ParseUnaryExpression(out bool, bool)
Microsoft.Ajax.Utilities.JSParser.ParseExpression(bool, Microsoft.Ajax.Utilities.JSToken)
Microsoft.Ajax.Utilities.JSParser.ParseExpressionList(Microsoft.Ajax.Utilities.JSToken)
Microsoft.Ajax.Utilities.JSParser.ParseMemberExpression(Microsoft.Ajax.Utilities.AstNode, System.Collections.Generic.List<Microsoft.Ajax.Utilities.Context>)
Microsoft.Ajax.Utilities.JSParser.ParseLeftHandSideExpression(bool)
Microsoft.Ajax.Utilities.JSParser.ParseUnaryExpression(out bool, bool)
Microsoft.Ajax.Utilities.JSParser.ParseExpression(bool, Microsoft.Ajax.Utilities.JSToken)
...
Possible Solution
No idea. Worked fine with chart.js 2.9.x.
Steps to Reproduce
Note that an "interactive example" is not applicable here. I just created a new MVC 5 application for Framework 4.8. The only change was adding a bundle for chart.js in BundleConfig.cs, then adding the RenderScript() for it in _Layout.cshtml. I have the solution zipped, but wasn't able to attach it. Happy to upload it wherever you like.
Context
Environment
Beta Was this translation helpful? Give feedback.
All reactions