Asp.net MVC5 WebRole after deployed to Azure Cloud, breaks on #Scripts.Render - asp.net-mvc

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

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.

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.

Related

How to resolved Combine external JavaScript file issue in asp.net mvc . I am using bundling for render java script file

error file snapshot
There are multiple resources served from same domain. Consider combining them into as few files as possible.
7 JavaScript resources served from localhost.
From the snapshot provided i see you are in debug mode (localhost). MVC bundler is only bundling individual files when your project is in release mode (debug=false in web.config). This ensures that you can access your individual js files while debugging with browser dev tools.

How to deploy PdfSharp to a webhost

I have everything working fine on my localhost. I included the lib directory in the project and did a web deploy. nothing is happening and no errors. all the console has for the Pdf webapi get call is a 200ok, and "no properties" inside it. IS there a mapping issue when you upload ?

How to deploy to production with entity framework code first

I'm coming from asp.net Web Forms switching to MVC and entity framework code first approach. I have a question. How can I set up my environment to deploy to production?
I'm using Visual Studio 2012 and deploys a web deploy package. Locally I have SQL Express and in production, I have SQL Server 2008.
What I want is to develop an test locally on my pc and from time to time deploy my solution to production with a web deploy package. I don't want to run migrations in the production system, instead, I want to generate scripts from visual studio which I then can append to production SQL.
I tried to:
Create Initial migration in dev.
Update database locally
Generate script, update-database -script -sourcemigration:InitialCreate
Apply this script in production
Deploy the application to production
Is this the correct approach? What about my migrations that will run locally, will they not in production to when I deploy because of my migrations code?
In global.asax
Migrator.RunMigrations();
where RunMigrations is a static method in a custom Migrator class like this
public class Migrator
{
public static void RunMigrations()
{
var migrator = new Configuration();
var dbMigrator = new System.Data.Entity.Migrations.DbMigrator(migrator);
if (dbMigrator.GetPendingMigrations().Any())
{
dbMigrator.Update();
}
}
}
You can with Web Setup Project (for the installation an MSI Custom Action is needed):
The actual work of updating the database is can be done by the migrate.exe tool. To make the MSI package run it properly turned out to be a bit of a challenge. I first included migrate.exe in the installation package to have it deployed to the bin directory together with the assemblies of the system. There is support for running a .exe file as a custom action in the web setup projects. Unfortunately, I couldn’t get migrate.exe to work unless the working directory was set to the bin directory. The working directory for custom actions is c:\windows\system32 by default. To handle that, a small vb-script was used.
http://coding.abel.nu/2012/04/update-database-msi-custom-action/
UPDATE:
I found this, this and this, maybe it will help.
Rollback all migrations
update-database -TargetMigration:0
update-database -Script
https://cpratt.co/migrating-production-database-with-entity-framework-code-first/

NullPointerException while deploying app on GlassFish Server 2.1

I am getting a NullPointerException when deploying an app on my GlassFish Server 2.1. It doesn't affect anything in my app, as it runs smoothly, but I would like to resolve this error during deployment.
Here is the stacktrace of the exception:
java.lang.NullPointerException
at org.apache.catalina.loader.WebappClassLoader.findResources(WebappClassLoader.java:1100)
at org.apache.catalina.loader.WebappClassLoader.getResources(WebappClassLoader.java:1349)
at com.sun.xml.ws.util.ServiceFinder$LazyIterator.hasNext(ServiceFinder.java:351)
at com.sun.xml.ws.api.pipe.TubelineAssemblerFactory.create(TubelineAssemblerFactory.java:104)
at com.sun.xml.ws.api.pipe.TubelineAssemblerFactory.create(TubelineAssemblerFactory.java:78)
at com.sun.xml.ws.client.WSServiceDelegate.createPipeline(WSServiceDelegate.java:419)
at com.sun.xml.ws.client.WSServiceDelegate.createEndpointIFBaseProxy(WSServiceDelegate.java:589)
at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:329)
at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:311)
at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:304)
at javax.xml.ws.Service.getPort(Service.java:92)
yes.you should not maintain commons-discovery.jar in glassfish\lib folder.Put it in the WEB-INF/lib folder of your project and not the C:\GlassFishESBv22\glassfish\lib folder, this should resolve your issue.
This problem occur when including commons-discovery.jar in your C:\GlassFishESBv22\glassfish\lib folder.

MVC4 Deployment Issues on Azure

I'm having a strange issue with Azure!
I just recently upgraded my azure deployed site from MVC3 to MVC4. I did this by creating a brand new MVC4 project which uses only Nuget packages so should be "bin deployable"? I copied only the essential sections across from my Web.config in the root and in the Views folder.
Everything works fine locally, but after deploying to Azure I find that the role is stuck in "Busy" but the website works! It also spontaneously recycles the instance (im guessing due to its busy status).
I added Intellitrace to the deployment, and it's complaining that this reference does not exist:
Unable to load the role entry point due to the following exceptions:
-- System.IO.FileLoadException: Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0'
I have no idea why it is trying to load an MVC Version 3 reference in a 4 project. I've searched the Web.configs for any references to 3.0.0.0 and the references for the project seem fine.
Please help! Are there any extra debugging steps i can take?
Thanks!
This seems to be the same question as http://social.msdn.microsoft.com/Forums/en-US/windowsazuredevelopment/thread/9c2f6b62-185d-4a38-8bb5-eda1917604d9. As pointed out in the other thread:
Have you configured assembly redirection? If you create a new Windows Azure project with a MVC 4 web role (now supported in SDK 1.7), you will see the following redirection:
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
I assume you have copy local set to true for the System.Web.Mvc reference so its being copied up in your deployment package?
I have the same problem upload my project to Azure,
In addition I did your recommends respectively ,
So It was necessary to create the my project a startup task and after that I generated script for this startup task . Check your hosted service and
I hosted service is windows Server R2 so I changed my ServiceConfiguration.Cloud.cscfg file .The OsFamily attribute is changed “1” to “2”.
You can find the more info in this link : Windows Azure Startup Tasks , It is written in Italian but you can translate it to English.

Resources