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
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.
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.
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.
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.
We corrected every web.config file so older versions were redirected to a newer version but we still had the same problem.
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.
Here is are 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("------------------------------------------------------------");
}
}
}
MVC 5.2.2 works perfectly fine in Azure. Your role recycling is most likely an indication that either you have not properly deployed your application properly or that you have a hidden dependency on an older version of MVC that a binding redirect may not handle.
I would strongly suggest that you read all of the entries in Kevin Williamson's great series on trouble shooting Azure deployments.
There are a ton of things that can go wrong, so rather than try to create a generic one-size-fits-all list, review the blog posts and then post a comment if you are unable to figure out what specifically is happening.
Given the error that you did post, assuming you have the proper binding redirect that #Yishai Galatzer mentions, 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 inspect all of your DLLs in your package and look at their references. I suspect you'll find one that itself depends on 5.1.0.0.
I have also face similar problem with mvc5.2.2 azure deployment..
the ultimate solution is 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>``
From the looks of it, looks like you are missing a binding redirect to MVC 5.2.2 in your web.config. This should just work.
We are working on verifying this scenario. But let us know if this works for you. In your web.config please take a look at the following section, and makes sure it matches with this 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>
I had exactly similar problem couple of days back. Please refer to this post.
You need to add <dependentAssembly> section to WaIISHost.exe.config which is generally # 'E:\base\x64' on your VM.
Many times I've found the problem to be in the ~\Views\Web.config file. It keeps a reference to the old MVC version. Just manually update it.
If that doesn't work do a full text search of your solution in Sublime Text or some other tool outside of VS and search for the version string causing you issues.
I had the same issue, where it worked fine on my Dev machine, but when deployed I was getting the assembly error. To resolve this, I had to change the "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>
To
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
</dependentAssembly>
Related
Use the Docusign API to send a Document for a signature
string accountId = loginApi(username, password, integratorKey);
Which then calls LoginAPI method which breaks at line:
LoginInformation loginInfo = authApi.Login();
Which should allow me to receive the accountId for my integrator key/login credentials
Instead I am getting an error of:
{"Method not found: 'RestSharp.IRestRequest RestSharp.RestRequest.AddFile(System.String, System.Action`1, System.String, System.String)'."}
Just started integrating Docusign into our application so using these versions which are dependencies to attempt to recreate this issue:
Docusign.eSign.dll V2.1.8
RestSharpv106.1.0
RestSharpSignedv105.2.3
Newtonsoft.Json v10.0.3
BouncyCastle v1.8.1
Any Idea?
This is because of RestSharp and RestSharpSigned have the same dll file name and one overwrites the other.
You should use RestSharpSigned only to avoid conflict.
I solved the issue by uninstalling RestSharp and its binding redirect in *.config file:
<dependentAssembly>
<assemblyIdentity name="RestSharp" publicKeyToken="598062e77f915f75" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-106.6.10.0" newVersion="106.6.10.0" />
</dependentAssembly>
Know this is a bit of an old one, but I had the same problem. As Nick suspected, the issue was down to a conflict between RestSharpSigned and RestSharp.
I uninstalled both and the DocuSign library, then re-installed RestSharpSigned, then DocuSign. Our other code that was using the standard RestSharp library seems to be working fine with the signed version.
I'm trying to write some unit tests, using NUnit, for code that relies on DbGeography.PointFromText(text, 4326), which requires Microsoft.SqlServer.Types be loaded. I'm trying to load it using:
[OneTimeSetUp]
public void Startup()
{
SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);
}
I have also tried to use load them in a [Setup] method. When the code that uses DbGeography is called, I end up with the lovely exception:
System.InvalidOperationException : Spatial types and functions are not
available for this provider because the assembly
'Microsoft.SqlServer.Types' version 10 or higher could not be found.
I do have the Microsoft.SqlServer.Types Nuget package installed, and it is working fine and dandy in my Web API 2.2 application.
You can install the libraries on the system, but then will also need to remember to install on build servers and production, etc.
Alternatively, have had success with doing the install of the Microsoft.SqlServer.Types NuGet and loading the assemblies as instructed. For xunit I included this in a TextFixure ctor.
SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);
Also, found I needed to add bindingRedirects:
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-14.0.0.0" newVersion="14.0.0.0" />
</dependentAssembly>
I ended up installing the Microsoft SQL Server CLR types, and my unit tests were able to find the necessary types.
X86 - http://go.microsoft.com/fwlink/?LinkID=239643&clcid=0x409
X64 - http://go.microsoft.com/fwlink/?LinkID=239644&clcid=0x409
I get this error message:
Could not load file or assembly 'System.Spatial, Version=5.7.0.0,
Culture=neutral, PublicKeyToken=49ba329had364evz' or one of its
dependencies. The located assembly's manifest definition does not
match the assembly reference. (Exception from HRESULT: 0x80131040)
I tried to uninstall/update System.Spatial and WindowsAzure.Storage Nuget packages but still get the error.
It's a dependency of WindowsAzure.Storage package, but funny thing is that I don't get this error when running my ASP.NET Web API project locally, but only on the Azure server.
I don't know where to find the assembly's manifest, is it packages.config?
How to get rid of this error? I already wasted two days :(
Changed the version details in configuration file based on DLL version present in bin folder of project having issue.
In configuration file it was referring to version 5.6.4 but I have changed to version 5.6.3 which resolved the error.
Before Change
<dependentAssembly>
<assemblyIdentity name="System.Spatial" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" />
</dependentAssembly>
After change.
<dependentAssembly>
<assemblyIdentity name="System.Spatial" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.6.3.0" newVersion="5.6.3.0" />
</dependentAssembly>
if you are using visual studio, go to nugget package manager and view installed packages, and use update pane to update system.spatial package,
this solved my issue
For some reason I don't know, Visual Studio wasn't uploading newer .dll file to the server.
So I manually uploaded System.Spatial version 5.7.0 on the server.
(although still I don't know how could I change the version in a so called manifest.)
Fit all dependencies to your current azure version by the following two steps:
open Package Manager Console window
enter PM> Install-Package WindowsAzure.Storage -Version [your_version_number]-preview -Pre
this is what solved the problem in my case.
I got an app with server code, now I try to run it on Photon Server, but I receive an exception with PhotonHostRuntimeInterfaces, I guess there is something wrong with version, I searched a lot for such a problem, but I'm really new in server programming, so can anyone help me with this issue?
Here is the log:
*System.Exception: Stop: unable to call the Application.TearDown() - undefined photonControl.
в PhotonHostRuntime.PhotonDomainManager.PhotonPlainAppDomainBehavior.Stop()
в PhotonHostRuntime.PhotonDomainManager.Stop()
6336: 10:34:55.862 - ERROR: Failed to start application: "RagingServer" in app domain: 2
6336: 10:34:55.863 - CService::OnException() - Exception: CManagedHost::StartApplication() - Failed to start application in AppDomain: 2 - Could not load file or assembly "PhotonHostRuntimeInterfaces, Version=3.56.0.0, Culture=neutral, PublicKeyToken=6cb1467adaa73020"or one of their dependencies. The obtained assembly manifest definition does not match the assembly reference (Исключение из HRESULT: 0x80131040)
6336: 10:34:55.863 - Server shutting down...*
I also found a solution like that:
<dependentAssembly>
<assemblyIdentity name="PhotonHostRuntimeInterfaces" publicKeyToken="6cb1467adaa73020" culture="neutral" />
<bindingRedirect oldVersion="3.56.0.0" newVersion="3.58.0.0" />
</dependentAssembly>
But I'm not sure where I should put in it, on my PhotonServer.config?
this is usually placed into your application config, which looks like AssemblyName.dll.config. take a look here for examples and docs
and you back to your problem, there is at least two options:
1. you mixed sdk versions. Photon SDK version v3.4.27 is using PhotonHostRuntimeInterfaces.dll, Version=3.56.0.0. You may find it in sdk lib folder and in 'deploy\bin_Win64'. newer versions of sdk use version 3.58 of PhotonHostRuntimeInterfaces.dll. Probable you upgraded your developer machine, but did not upgrade your server
you forgot to add this dll at all. it should be in bin folder of your application
hope this will help you
-The Photonians
I'm using AspNet Web Api Client 5.0 and i am trying to unit test a web api controller.
var encservice = new EncryptionService();
var acctservice = FakeServices.GetAccountService();
var controller = new AccountController(acctservice, encservice);
controller.Request = new HttpRequestMessage();
when the code
controller.Request.SetConfiguration(new HttpConfiguration());
is executed i hit an exception
Message: Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source: System.Net.Http.Formatting
Stacktrace: at System.Net.Http.Formatting.JsonMediaTypeFormatter..ctor()
at System.Net.Http.Formatting.MediaTypeFormatterCollection.CreateDefaultFormatters()
at System.Net.Http.Formatting.MediaTypeFormatterCollection..ctor()
at System.Web.Http.HttpConfiguration.DefaultFormatters()
at System.Web.Http.HttpConfiguration..ctor(HttpRouteCollection routes)
at System.Web.Http.HttpConfiguration..ctor()
at EMR.Test.Controller.AccountControllerTest.Should_Get() in c:\PremiumProjectsCollection\emr\src\EMRAzure\EMRAzure\EMR.Test\Controller\AccountControllerTest.cs:line 34
the version of newsoft.json that i am using is 6.0
I also have a assembly redirection in my confguration file
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
The test runner that im using is MStest, VS2012
You'll need to add an assembly redirect:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json"
publicKeyToken="30ad4fe6b2a6aeed"
culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
(assuming that the assembly version of Newtonsoft.Json is exactly 6.0.0.0.)
(note comment below is referring to a Web Api Client project having this issue)
I had the same problem with the version of Newtonsoft.Json so I deleted the older version references and used Package Manager Console to install the latest version of Newtonsoft.Json on my Web Api Client Library and Test Project.
Install-Package Newtonsoft.Json -Version 6.0.8
(note u might need to find out which is the latest version)
The problem remained so I realized there is a crash between System.Net.Http.Formatting and my latest version of Json.
To solve this, delete the System.Net.Http and System.Net.Http.Formatting references and install the WebApi Client Library via Nuget instead, as below:
Install-Package Microsoft.AspNet.WebApi.Client
This solved it for me.
I did not try this myself, but there seems to be a bug in 2012 mstest. Where you have to use .testsettings file for app.config to be picked up.
See the following link: http://social.msdn.microsoft.com/Forums/vstudio/en-US/234926d1-42c0-4ebb-af39-1626e72f6c39/why-does-assemblybinding-work-only-if-testsettings-file-is-used-vs2012rc?forum=vsunittest
I faced the same problem days ago and it took me hours to find a solution for this one.
I was testing a unit that had the latest version of NewtonSoft installed while my test project had an older version.
What i did to get around this was consolidate the versions of this library in my solution via the "Manage Nuget packages for solution" option by right clicking the solution in solution explorer.
This will update all NewtonSoft libraries present in your projects under the current solution and remove all old versions from the package control VisualStudio creates in a folder named packages in your solution directory.