[英]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. 我们使用MVC3和Entity Framework 4.1在.Net Framework 4上构建了C#Web应用程序。 The application is running in Windows Azure and is working against a SQL-Azure database.
该应用程序在Windows Azure中运行,并且正在处理SQL-Azure数据库。 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. 使用从我们的svn中检出的完全相同的代码,在一台计算机上通过Visual Studio部署应用程序时,一切正常,但是,在另一台计算机上执行相同的操作,则无论使用哪种控制器/,该应用程序均会返回404错误您想要达到的动作。 The application works smooth in the Cloud Emulator on both computers.
该应用程序可在两台计算机上的Cloud Emulator中顺利运行。 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.
我们还尝试将应用程序打包在错误的计算机上,并通过Azure Web门户对其进行部署,但这也不起作用。
Both computers are running Windows 7 64-bit, with Visual Studio 2010 Ultimate and the Azure SDK installed. 两台计算机都运行Windows 7 64位,并安装了Visual Studio 2010 Ultimate和Azure SDK。
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. 编辑:使用RDP(感谢提示!@Ben),我认为我们离解决方案更近了。 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 appDomainCreationException)
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. 奇怪的是,该特定的dll-Microsoft.Web.Infrastructure.dll包含在我的_bin_deployableAssemblies文件夹中。
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.
由于某种原因,一台计算机缺少一些必需的引用(如我编辑的问题中的错误所示,Microsoft.Web.Infrastructure,System.Web。我不知道两台计算机之间的区别如何,因为我们正在使用完全相同的来源,但显然是的。
Thanks @Ben for your tip on Remote Desktop, that sure helped a lot. 感谢@Ben为您提供有关远程桌面的提示,这确实有很大帮助。
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 对于那些对在Azure实例上使用远程桌面感兴趣的人,请阅读Microsoft关于该主题的精彩文章: http : //msdn.microsoft.com/zh-cn/library/gg443832.aspx
I had this error on an Azure webrole instance. 我在Azure webrole实例上遇到此错误。 Make sure you add the Microsoft.Web.Infrastructure reference to your project.
确保将Microsoft.Web.Infrastructure引用添加到您的项目。
But most importantly view properties for the Infrastructure reference, and set Copy Local = True . 但最重要的是,查看基础结构引用的属性,并设置Copy Local = True 。
This will ensure the missing ref is bundled in with your solution, when it's deployed. 这将确保在部署解决方案时将缺少的引用与您的解决方案捆绑在一起。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.