This is similar to Odd Exception in MVC 3 Project.
We have an ASP.NET 4.0 application running in full trust. We need to have the following line in our web.config, otherwise one of the libraries we are using does not function. (As it explicitly uses the now obsolete CAS model from previous versions of .NET).
<trust legacyCasModel="true" />
Given this setting, we are unable to use the dynamic keyword or certain features of ASP.NET MVC which rely on it.
As an example, the following code causes an exception:
dynamic d = new object();
d.test = "jason";
The exception is:
Dynamic operations can only be performed in homogenous AppDomain.
Is there any way I can make the dynamic keyword work if legacyCasModel is set to true? (If set to false, everything works fine, except the library that requires it.)
Ideas:
Given that I am running in full trust, I assume that one assembly in the AppDomain is utilizing reduced permissions (hence the non-homogeneous). Is there a way I can simply tell it to run in full trust mode, making the AppDomain homogeneous?
Should I be able to refactor my code somehow to load the problematic assembly in another AppDomain? I'm not familiar with typical ways of doing this, but it appears complex.
Is there some other magical configuration setting I can enable to make it work?