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
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.
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.