System.Security.SecurityException: That assembly does not allow partially trusted callers

26 Aug 2009

I was writing a Windows Azure ASP.NET MVC application and when making a call to a page I received the following exception:

System.Security.SecurityException: That assembly does not allow partially trusted callers

In my application I'm using Castle Windsor for dependency injection and when trying to resolve a service using:

}

IGravatar gravatar = MvcApplication.Container.Resolve<IGravatar>();

I received this message. To solve things I needed to update the WebRole element in the ServiceDefinitions.csdef file so that enableNativeCodeExecution is enabled.

<WebRole name="TwitterGravatarMVC" enableNativeCodeExecution="true">

I found the solution, detailed above, on the Azure Services Platform Developer Centre forum.