簡體   English   中英

Azure上的Asp.net MVC 5.2.2

[英]Asp.net MVC 5.2.2 on Azure

將mvc nuget軟件包從版本5.1.0升級到5.2.2后,Azure上的機器(webrole)拒絕啟動Web角色。 它處於回收狀態。 我在事件日志中發現了一個錯誤:

    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正在運行。

更新1:在我發現一些試驗和錯誤之后,asp.net mvc軟件包在5.1.3版本之前就可以了。看起來不支持5.2.0以上的軟件包。

更新2:我們決定拆分我們的web和web.api,所以我不再有這個問題了。 我最好的猜測是,確實有nuget,它引用了較舊的asp.net mvc包。

我遇到了類似的問題。 我們繼承了一個項目並將ASPNET MVC版本更新為5.2.2.0。 我們無法部署到Azure。 我們唯一能找到的錯誤是你在這里提到的錯誤。

我們更正了每個web.config文件,因此舊版本被重定向到更新版本但我們仍然遇到了同樣的問題。

然后我們編寫了一個小的測試方法,遍歷每個Assembly,我們看到一個NuGet包仍在使用Asp.net MVC 4.0。 這個包是舊版本,暫時沒有更新。 我下載了源代碼,更新了Mvc Nuget並手動插入了dll。

我們再次部署,一切都完美無瑕。

這是測試方法。

 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("------------------------------------------------------------");
            }
        }
    }

MVC 5.2.2在Azure中運行得非常好。 您的角色回收很可能表明您未正確部署應用程序,或者您對綁定重定向可能無法處理的舊版MVC具有隱藏依賴性。

我強烈建議您閱讀Kevin Williamson 關於解決Azure部署問題精彩系列中的所有條目。

有很多事情可能會出錯,因此,如果您無法弄清楚具體發生的情況,請查看博客文章,然后發表評論,而不是嘗試創建通用的“一刀切”列表。

鑒於您發布的錯誤,假設您有@Yishai Galatzer提到的正確綁定重定向,您的部署中可能有一個DLL,它對MVC 5.1.0.0有隱藏的依賴關系。 我建議使用像Jetbrains DotPeek這樣的程序檢查包中的所有DLL並查看它們的引用。 我懷疑你會發現一個本身依賴於5.1.0.0。

I have also face similar problem with mvc5.2.2 azure deployment..

最終的解決方案是我們需要添加這個web.config

<dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
</dependentAssembly>``

從它的外觀來看,您似乎缺少web.config中綁定重定向到MVC 5.2.2。 這應該工作。

我們正在努力驗證此方案。 但是,如果這對您有用,請告訴我們。 在您的web.config中,請查看以下部分,並確保它與下面的xml匹配:

<dependentAssembly> <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-5.2.2.0" newVersion="5.2.2.0" /> </dependentAssembly>

幾天前我有類似的問題。 請參考這篇文章。 您需要將<dependentAssembly>部分添加到WaIISHost.exe.config ,這通常是您的VM上的@ 'E:\\ base \\ x64'

很多次我發現問題出現在〜\\ Views \\ Web.config文件中。 它保留了對舊MVC版本的引用。 只需手動更新它。

如果這不起作用,請在Sublime Text或VS之外的其他工具中對您的解決方案進行全文搜索,並搜索導致問題的版本字符串。

我遇到了同樣的問題,它在我的Dev機器上運行良好,但是在部署時我得到了匯編錯誤。 要解決此問題,我必須將“oldVersion”從版本0.0.0.0更改為版本1.0.0.0

<dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="0.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
</dependentAssembly>

<dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
</dependentAssembly>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM