I get this error in my ASP.Net application:
"Attempt by security transparent method Field.set_FieldType(Constants.DataTypeEnum) to access security critical type Constants.DataTypeEnum failed."
The security critical type DataTypeEnum is a public enumerated type in an assembly which has the AllowPartiallyTrustedCallers attribute. (Also DataTypeEnum is declared outside of any class or module). It does not have the SecurityCritical attribute.
Shouldn't it therefore by default be SecurityTransparent?
Does anyone know why it is SecurityCritical?
Update
I am trying to dynamically load and run code in a sandbox/remote appdomain.
I am not getting the error now. Tried a number of things. Tried putting enums inside a module. At one point I was getting the error, "The located assembly's manifest definition does not match the assembly reference", for the Constants assembly which is used by the sandbox code. I killed the ASP.Net process and deleted the app sub-directory in 'Windows\Microsoft.NET\Framework\Temporary ASP.Net Files' and now it is working.
If I declare the enums outside a module I now get the error "Could not load type 'Constants.ReportType' from assembly ...". If I put them back in a module it works but I am not convinced this is reason for the original error.