4
votes

I have a cloud service with an Asp.Net MVC 5 Web Role and Azure SDK 2.3 targeting 4.5.1 framework; The website works perfectly in Local. But when I deploy it to Azure Cloud service, I have the classic null reference error:

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

Source Error:

Line 9:      @Scripts.Render("~/bundles/jquery")

My BundleConfig.cs is simple:

    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                     "~/Scripts/jquery-{version}.js",
                     "~/Scripts/knockout-{version}.js",
                     "~/Scripts/jquery.signalR-{version}.js",
                     "~/Scripts/modernizr-{version}.js"
                    ));

Using Intellitrace Logs on the WebRole I can see this error:

invalid file name for file monitoring 'E:\sitesroot\0\Scripts

Entering remotely in the instance I see that the folder Scripts is exactly in that path.

Removing the @Script.Render the page load normally. The @Style.Render on the same page works.

I tried to deploy in Debug mode, and Release mode, both in Staging.

Also tried to change in Web.config the

compilation debug="true" and false

with no success. Any ideas why could happen this? Thanks

2
Are all the files referenced in the bundle deployed (jquery, knockout, jquery.signalR & modernizr)? Min and non-min versions?viperguynaz
Yes, the files are there, I also checked the instance via Remote connection, are all in the Script folder. I really cannot figure out what it is!Francesco Cristallo

2 Answers

4
votes

After days of tests I discovered that the problem is the WEBGREASE package. Updating it will cause the problem even on a fresh new project. For now uninstalling it and reinstalling the previous version solved the problem.

0
votes

Try removing everything but jquery from the jquery bundle. Then create a new bundle for the jquery dependent scripts (knockout, jquery.signalR & modernizr) and render it after the jquery bundle.