Asp.net MVC 5.2.2在Azure上 [英] Asp.net MVC 5.2.2 on Azure

查看:265
本文介绍了Asp.net MVC 5.2.2在Azure上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从5.1.0版本升级MVC的NuGet包在Azure 5.2.2我们的机器(webrole)后拒绝启动Web角色。这是在循环状态。我发现在事件日志中的错误:

After upgrading mvc nuget package from version 5.1.0 to 5.2.2 our machine (webrole) on Azure refuses to start the web role. It was in recycling state. I found an error in event log :

    The description for Event ID 1007 from source Windows Azure Runtime 2.4.0.0 cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.

If the event originated on another computer, the display information had to be saved with the event.

The following information was included with the event: 

820
WaIISHost
Role entrypoint could not be created: System.TypeLoadException: 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=5.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'System.Web.Mvc, Version=5.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

 ---> System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.RuntimeModule.GetTypes()
   at System.Reflection.Assembly.GetTypes()
   at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetRoleEntryPoint(Assembly entryPointAssembly)
   --- End of inner exception stack trace ---
   at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetRoleEntryPoint(Assembly entryPointAssembly)
   at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.CreateRoleEntryPoint(RoleType roleTypeEnum)
   at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeRoleInternal(RoleType roleTypeEnum) 
the message resource is present but the message is not found in the string/message table

我试图寻找在互联网上,但没有有用的答案。
我无法以其他方式解决它比降级。幸运的是包版本5.1.1工作。

I tried to search over the internet, but with no useful answer. I wasn't able to solve it otherwise than downgrade. Luckily package version 5.1.1 is working.

更新1:
一些试验和错误我发现,ASP.NET MVC包确定了5.1.3版本后
它看起来像不支持从5.2.0以上的包。

Update 1: After some trial and error I found, that asp.net mvc packages are OK up to version 5.1.3 It looks like packages from 5.2.0 upwards are not supported.

更新2:
我们已经决定分裂我们的网站和web.api,所以我就没有这个问题了。我最好的猜测是,确实有的NuGet,这是参照旧的asp.net的MVC包。

Update 2: We have decided to split our web and web.api, so I didn't have this problem anymore. My best guess is, that there was indeed nuget, which was referencing older asp.net mvc package.

推荐答案

我有一个类似的问题。我们继承了一个项目,并更新了ASPNET MVC版本5.2.2.0。我们不能部署到Azure上。我们所能找到的唯一错误是你在这里提到的。

I had a similar problem. We inherited a project and updated the ASPNET MVC version to 5.2.2.0. We couldn't deploy to Azure. The only error we could find was the one you mentioned here.

我们纠正每个web.config文件,以便旧版本重定向到一个新的版本,但我们仍然有同样的问题。

We corrected every web.config file so older versions were redirected to a newer version but we still had the same problem.

然后,我们写了一个遍历所有的大会小测试方法,我们看到一个包的NuGet仍在使用Asp.net MVC 4.0。这个包是一个老版本,一段时间没有更新。我下载的来源,更新了MVC的NuGet并手动插入DLL。

Then we wrote a small test method that iterated over every Assembly and we saw that one NuGet package was still using Asp.net MVC 4.0. This package was an old version and hadn't been updated for a while. I downloaded the source, updated the Mvc Nuget and manually inserted the dll.

我们再部署,一切都完美无瑕。

We deployed again and everything went flawless.

在这里是测试方法。

 private void TestAssemblies()
    {
        var allAssemblies = AppDomain.CurrentDomain.GetAssemblies();
        foreach (Assembly item in allAssemblies)
        {
            PrintAssembly(item);
        }
    }
    private void PrintAssembly(Assembly assembly)
    {
        foreach (var item in assembly.GetReferencedAssemblies())
        {
            if (item.FullName.Contains("System.Web.Mvc"))
            {

                Debug.WriteLine(item);
                Debug.WriteLine("Parent: " + assembly.FullName);
                Debug.WriteLine("------------------------------------------------------------");
            }
        }
    }

这篇关于Asp.net MVC 5.2.2在Azure上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆