0

I have an MVC 4 app deployed to an Azure cloud service that has worked for months. Suddenly the app has stopped working, and I see 401 errors on a page that allows anonymous access. Digging into the event log reveals this:

<EventData>
 <Data>System.AppDomain/50824127</Data>
 <Data>System.Runtime.Serialization.SerializationException: Type is not resolved for member 'Microsoft.IdentityModel.Claims.ClaimsPrincipal,Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. at System.Web.Hosting.ApplicationManager.GetUpdatedTotalCacheSize(Int64 sizeUpdate) at System.Web.Hosting.ObjectCacheHost.System.Runtime.Caching.Hosting.IMemoryCacheManager.UpdateCacheSize(Int64 size, MemoryCache memoryCache) at System.Runtime.Caching.CacheMemoryMonitor.GetCurrentPressure() at System.Runtime.Caching.MemoryMonitor.Update() at System.Runtime.Caching.MemoryCacheStatistics.CacheManagerThread(Int32 minPercent) at System.Threading.ExecutionContext.runTryCode(Object userData) at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) at System.Threading._TimerCallback.PerformTimerCallback(Object state)</Data>
 <Data>w3wp</Data>
 <Data>2548</Data>
 </EventData>

After hours and hours of troubleshooting and inspecting configurations, I am unable to figure out a reason why this would be happening. The assembly, Microsoft.IdentityModel, 3.5.0.0 is in the bin folder in the deployment package, and the project has the correct references to the WIF nuget packages.

What's worse is that my project works in one azure cloud service, but not in another (which fails as described above). There seem to be a limited number of related questions, such as Type is not resolved for member "Microsoft.IdentityModel.Claims.ClaimsPrincipal,Microsoft.IdentityModel", but this one has to do with running sitefinity on a developer workstation, and my problem is in the cloud.

Any ideas?

Community
  • 1
  • 1
Ben Collins
  • 20,538
  • 18
  • 127
  • 187
  • As far as I am aware, if you are running .NET 4.5, you no longer need a startup task, as the new assemblies come from the GAC. You might make sure you're not getting WIF and the newer Microsoft.IdentityModel namespaces mixed up. See my answer to my own question here: http://stackoverflow.com/a/12950590/1014822 – Jude Fisher Feb 13 '13 at 13:34
  • I'm still on .NET 4 with this app. – Ben Collins Feb 14 '13 at 14:43
  • Then the answer below is correct: you need to run a startup task to install WIF. Just having the .dll in the bin folder won't do it. Details here: http://stackoverflow.com/a/10206387/1014822 – Jude Fisher Feb 14 '13 at 15:42
  • @JcFx - that make all the sense in the world, except that I am able to deploy the exact same code in another azure compute service, and it works fine, and it's driving me crazy that I haven't been able to figure out why yet. – Ben Collins Feb 15 '13 at 17:10

1 Answers1

1

We had an similar issue in our Azure project, but not exactly the same. Our error was

Unable to Find Assembly 'Microsoft.IdentityModel'

The reason is Azure virtual machines don't have WIF on them by default. Even if we have Microsoft.IdentityModel in our bin folder, when application try to resolve the reference to Microsoft.IdentityModel, and even though it's unrelated, it fails and throw the missing reference error.

This issue can fixed by Installing WIF in a startup task. This link contains detais to how to do that.

http://blogs.msdn.com/b/sriharsha/archive/2012/04/07/windows-azure-unable-to-find-assembly-microsoft-identitymodel.aspx

ssilas777
  • 9,672
  • 4
  • 45
  • 68