Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to find assembly 'Microsoft.IdentityModel" error on azure

I am using ACS authentication for my MVC3 web application.It is working perfectly fine on my local machine.But when I upload this to Azure.I am getting this error . I set CopyLocal=True ,please help

Unable to find assembly 'Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Runtime.Serialization.SerializationException: Unable to find assembly 'Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  
like image 246
Lee Avatar asked Dec 27 '22 02:12

Lee


2 Answers

More info on this. Copy Local, ie. ensuring that Microsoft.IdentityModel.dll is in the bin directory, will work unless your code uses the RoleEnvironment API. If this is the case then you will run into the following known issue:

http://msdn.microsoft.com/en-us/library/windowsazure/hh403974.aspx

In this case, Microsoft.IdentityModel will need to exist in the GAC of your Azure VM. To accomplish this, use a startup task. This post describes two ways to accomplish this:

http://blogs.infosupport.com/adding-assemblies-to-the-gac-in-windows-azure/

like image 94
ktam33 Avatar answered Mar 03 '23 23:03

ktam33


I work for Microsoft. We've removed this article at hh403974.aspx because of low hits, but I see that it still gets a few referrals from this thread, so I'm going to paste the contents of the article below.

Unable to Find Assembly 'Microsoft.IdentityModel' When RoleEnvironmentAPIs are Called

Applies to: Applies to SDK1.3 and later using a full IIS web role and Windows Identity Foundation.

Symptom: You encounter the following exception on the first call to a RoleEnvironment method.

[SerializationException: Unable to find assembly 'Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.]

Cause: The Windows Identity Foundation assemblies are not properly installed to the Azure virtual machine.

Resolution: Use a startup task to reinstall the Windows Identity Foundation package on the virtual machine.

For more information on using startup tasks, see Run Startup Tasks in Azure.

like image 40
Rob Boucher Jr Avatar answered Mar 03 '23 22:03

Rob Boucher Jr