C# web application causes 404 error in Azure when deployed from one computer, but not from another
We have built a C# web application on .Net Framework 4, using MVC3 and Entity Framework 4.1. The application is running in Windows Azure and is working against a SQL-Azure database. When we deploy the application, we run in to a somewhat weird problem.
Using the exact same code, checked out from our svn, when deploying the application through Visual Studio on one computer everything works fine, however, doing the exact same thing on another computer causes the application to return a 404 error, no matter what controller/action you are trying to reach. The application works smooth in the Cloud Emulator on both computers. We have also tried to package the application on the erroneous computer, and deploy it through the Azure web portal, but that doesn't work either.
Both computers are running Windows 7 64-bit, with Visual Studio 2010 Ultimate and the Azure SDK installed.
Any ideas on why this could be?
Regards, Christofer
Edit: Using RDP (thanks for the tip! @Ben) I think we've got a bit closer to the solution. On the server, the following exception is thrown:
Exception information:
Exception type: InvalidOperationException
Exception message: The pre-application start initialization method Start on type System.Web.WebPages.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified..
at System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods)
at System.Web.Compilation.BuildManager.CallPreStartInitMethods()
at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCre开发者_如何学JAVAationException)
Could not load file or assembly 'Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
at System.Web.WebPages.PreApplicationStartCode.Start()
The weird thing is that that particular dll - Microsoft.Web.Infrastructure.dll is included in my _bin_deployableAssemblies folder.
I found the solution. For some reason, one computer was lacking some of the required references (Microsoft.Web.Infrastructure, System.Web, as seen in the error in my edited question. I don't know how that could differ between the two computers, as we were using the exact same source, but apparently it did.
Thanks @Ben for your tip on Remote Desktop, that sure helped a lot.
For those interested in using remote desktop on your Azure instance, read Microsoft's great article on the topic: http://msdn.microsoft.com/en-us/library/gg443832.aspx
I had this error on an Azure webrole instance. Make sure you add the Microsoft.Web.Infrastructure reference to your project.
But most importantly view properties for the Infrastructure reference, and set Copy Local = True.
This will ensure the missing ref is bundled in with your solution, when it's deployed.
精彩评论