Showing posts with label ASP.NET MVC 5. Show all posts
Showing posts with label ASP.NET MVC 5. Show all posts

Thursday, August 28, 2014

JavaScript runtime error: Unable to get property 'call' of undefined or null reference

I got this error after I had installed a NuGet package with editor templates for Bootstrap for ASP.NET MVC 5.

The solution consisted of 2 steps:
First, install package JQuery Migrate. Second, edit the method RegisterBundles in class BundleConfig from App_Start folder and change the part where it adds the bundle jqueryval.

Initially, in my project, it looked like this:

bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                          "~/Scripts/jquery.validate*"
                        ));


Here you have to add a line to include the jquery-migrate files:

bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                        "~/Scripts/jquery-migrate*",
                        "~/Scripts/jquery.validate*"
                        ));



Monday, July 21, 2014

Could not load file or assembly 'WebGrease, Version=1.5.1.25624, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies

I was working on a MVC 5 project in Visual Studio 2013, and I was getting the error in the title everytime I was trying to run the project. We were using Visual SVN for the versioning and I was the only one in my team that had this problem.

The only thing that worked for me was this:
  1. Uninstall Microsoft.AspNet.Web.Optimization
  2. In Nuget command prompt run: install-package Microsoft.AspNet.Web.Optimization -Version 1.0.0

This will install an older version of Web.Optimization. The project was initially referencing version 1.1.0. The problem is not with WebGrease, but with the System.Web.Optimization.dll that is referencing an old, inexisting version of WebGrease.

When I ran the project, it worked, but I wanted to use the same package version as the rest of team. So, I tried to update but... the error returned...

After this, I deleted the project (again) and took it back from the SVN. To my surprize, it started to work... The thing is that I had deleted the project completely and took it from the SVN several times before this. I even took the dlls from a colleague because I thought that maybe I'm getting corrupted files from NuGet, but to no avail.

Strange...