Asp.net MVC 5.2.2 on Azure

After updating the mvc nuget package from 5.1.0 to 5.2.2, our machine (webrole) on Azure refuses to start the web role. It was recyclable. I found an error in the 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 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

      

I tried to search the web but no helpful answer. I could not solve it otherwise how to downgrade. Fortunately, version 5.1.1 of the package works.

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

Update 2: We decided to split our website and web.api so I didn't have this problem anymore. My best guess is that there really was a nuget that referenced the old asp.net mvc package.

+3


source to share


7 replies


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

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

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



We turned around again and everything went flawlessly.

Here's a test method.

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

      

+4


source


MVC 5.2.2 works great in Azure. Your role replication is most likely a sign that either you misplaced your application as expected, or you have a hidden dependency on an older version of MVC that binding redirection might not handle.

I would highly recommend that you read all the posts in Kevin Williamson's excellent series on troubleshooting Azure deployment issues .



There are a lot of things that can go wrong, so instead of trying to create a one-size-fits-all list of all sizes, look at the blog posts and then post a comment if you can't figure out what exactly is going on.

Given the bug you posted, if you have the correct link forwarding mentioned by @Yishai Galatzer, you might have a DLL in your deployment that has a hidden dependency on MVC 5.1.0.0. I would suggest using a program like Jetbrains DotPeek to check all your DLLs in your package and see their references. I suspect you will find one that itself depends on 5.1.0.0.

+2


source


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

      

final solution - we need to add this 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>``

      

+2


source


It looks like you are missing the MVC 5.2.2 binding redirection in your web.config. This should work.

We are working to validate this scenario. But let us know if this works for you. In your web.config, please have a look at the following section and make sure it matches that xml below:

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

+1


source


I had a similar problem a couple of days ago. See this article. You need to add a section <dependentAssembly>

to WaIISHost.exe.config , which is usually @ 'E: \ base \ x64' in your virtual machine.

0


source


Many times I found the problem in the ~ \ Views \ Web.config file. It contains a link to the older version of MVC. Just update it manually.

If that doesn't work, do a full text search for your solution in Sublime Text or some other tool outside VS and look for the version line causing the problems.

0


source


I had the same problem, where it worked fine on my Dev machine, but I was getting a build error when deploying. To fix this problem I had to change "oldVersion" from version 0.0.0.0 to version 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>

      

For

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

      

0


source







All Articles