4

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

Francesco Cristallo
  • 2,856
  • 5
  • 28
  • 57
  • Are all the files referenced in the bundle deployed (jquery, knockout, jquery.signalR & modernizr)? Min and non-min versions? – viperguynaz Jun 03 '14 at 17:17
  • 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 Jun 04 '14 at 00:25

2 Answers2

4

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.

Francesco Cristallo
  • 2,856
  • 5
  • 28
  • 57
  • 1
    How did you track this to WebGrease - I got the same problem - upgraded a load of packages, MVC5, WeApi2 etc, and WebGrease got updated in the process to v 1.6 When I reverted WebGrease back to version 1.5.2 it worked. I would still like to know why, but thanks for your help – Peter Kerr Jan 07 '15 at 17:16
0

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.

viperguynaz
  • 12,044
  • 4
  • 30
  • 41
  • Done, nothing change, same error, I also tried to create a total new MVC project as WebRole with individual authentication and have the same identical problem. An MVC project without authentication instead deploy and run perfectly.. – Francesco Cristallo Jun 04 '14 at 08:14