Hi guys, I'm getting this exception when I set trust level to high or medium in web.config (VS2008 .NET 3.5 SP1):
EXCEPTION: System.ArgumentException: Error serializing value 'Collection of entities of type 'EntityBase2'. Current number of elements: 1' of type 'SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionNonGeneric.' ---> System.Security.SecurityException: Request failed.
at System.Reflection.CustomAttribute._CreateCaObject(Void* pModule, Void* pCtor, Byte** ppBlob, Byte* pEndBlob, Int32* pcNamedArgs)
at System.Reflection.CustomAttribute.CreateCaObject(Module module, RuntimeMethodHandle ctor, IntPtr& blob, IntPtr blobEnd, Int32& namedArgs)
at System.Reflection.CustomAttribute.GetCustomAttributes(Module decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit)
at System.RuntimeType.GetCustomAttributes(Type attributeType, Boolean inherit)
at System.ComponentModel.ReflectTypeDescriptionProvider.ReflectGetAttributes(Type type)
at System.ComponentModel.ReflectTypeDescriptionProvider.ReflectedTypeData.GetAttributes()
at System.ComponentModel.TypeDescriptor.TypeDescriptionNode.DefaultTypeDescriptor.System.ComponentModel.ICustomTypeDescriptor.GetAttributes()
at System.ComponentModel.TypeDescriptor.GetAttributes(Type componentType)
at System.ComponentModel.ReflectTypeDescriptionProvider.ReflectedTypeData.GetConverter(Object instance)
at System.ComponentModel.ReflectTypeDescriptionProvider.GetConverter(Type type, Object instance)
at System.ComponentModel.TypeDescriptor.TypeDescriptionNode.DefaultTypeDescriptor.System.ComponentModel.ICustomTypeDescriptor.GetConverter()
at System.ComponentModel.TypeDescriptor.GetConverter(Type type)
at System.Web.UI.ObjectStateFormatter.SerializeValue(SerializerBinaryWriter writer, Object value)
The action that failed was:
InheritanceDemand
The type of the first permission that failed was:
System.Security.PermissionSet
The Zone of the assembly that failed was:
MyComputer
--- End of inner exception stack trace ---
at System.Web.UI.ObjectStateFormatter.SerializeValue(SerializerBinaryWriter writer, Object value)
at System.Web.UI.ObjectStateFormatter.Serialize(Stream outputStream, Object stateGraph)
at System.Web.UI.ObjectStateFormatter.Serialize(Object stateGraph)
at System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Serialize(Object state)
at System.Web.UI.Util.SerializeWithAssert(IStateFormatter formatter, Object stateGraph)
at System.Web.UI.HiddenFieldPageStatePersister.Save()
at System.Web.UI.Page.SavePageStateToPersistenceMedium(Object state)
at System.Web.UI.Page.SaveAllState()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
I have llblgenprodatasource2 on the page:
<llblgenpro:LLBLGenProDataSource2 ID="FromAddressListLDS" runat="server"
AdapterTypeName="DAL.DatabaseSpecific.DataAccessAdapter, DALDBSpecific"
DataContainerType="EntityCollection"
EntityFactoryTypeName="DAL.FactoryClasses.FromAddressEntityFactory, DAL"
EnablePaging="True">
</llblgenpro:LLBLGenProDataSource2>
For trust level set to Full everything's working fine. If I add attribute CacheLocation="Session" for the LLBLGenProDataSource2, it is working fine even for high/medium trust level.
The problem is that I need to have CacheLocation set to 'ViewState' (default value), cannot use Session, and 'None' value breaks it completely.
I'd say this can be easily replicated with a gridview, llblgenprodatasource2, and trust level set to high/medium.
I think the problem is hidden in this:
The action that failed was:
InheritanceDemand
The type of the first permission that failed was:
System.Security.PermissionSet
I googled for couple of hours how to fix this 'InheritanceDemand' for 'PermissionSet', but was not successful.
I'd appreciate some help!! Cheers.