I have some problems with my MVC c# project.
First I receive this error: Level 2 transparency causes all methods in AllowPartiallyTrustedCallers assemblies to become security transparent by default, which may be the cause of this exception. complete:
Attempt by security transparent method 'System.Runtime.Diagnostics.DiagnosticTrace..ctor(System.String, System.Guid)' to access security critical method 'System.Runtime.Diagnostics.EtwDiagnosticTrace..ctor(System.String, System.Guid)' failed.
Assembly 'System.ServiceModel.Internals, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is marked with the AllowPartiallyTrustedCallersAttribute, and uses the level 2 security transparency model. Level 2 transparency causes all methods in AllowPartiallyTrustedCallers assemblies to become security transparent by default, which may be the cause of this exception."
Consequently I searched on the internet and two possibilities to solve it are found. The first works by including this snippet in assemblyinfo.cs
:
[assembly: System.Security.AllowPartiallyTrustedCallers]
but nothing changed..
Googling I found a second information saying that If I place in web.config
it probably work.
<trust legacyCasModel="true" level="Full" />
But when I placed that info in web.config
I receive and error like
Dynamic operations can only be performed in homogenous AppDomain
I don't know what else do I have to do...
I believe that using microsoft.practices.unity with ASP.NET 4.0 and mvc 4, is the main cause of the problem. But using unity for me is necessary based on the way my app works.
brgds! sebastian.