Print Page | Close Window

Designer Error both Blend & Visual Studio

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3350
Printed Date: 13-Apr-2026 at 5:57pm


Topic: Designer Error both Blend & Visual Studio
Posted By: splace
Subject: Designer Error both Blend & Visual Studio
Date Posted: 20-Mar-2012 at 4:54pm
Devforce 6.1.6.0 express, 
Silverlight 5.0
Visual Studio 2010 SP1

Whenever I try to reference in a DataContext of one of my code first DevForce classes in a designer (both blend and visual studio), I get the following exception:

Attempt by security transparent method 'DynamicClass.ReadEntityModelMetadataFromXml(System.Runtime.Serialization.XmlReaderDelegator, System.Runtime.Serialization.XmlObjectSerializerReadContext, System.Xml.XmlDictionaryString[], System.Xml.XmlDictionaryString[])' to access security critical type 'IdeaBlade.EntityModel.EntityModelMetadata' failed.

Assembly 'System.Runtime.Serialization, Version=5.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' 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.
   at ReadEntityModelMetadataFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] )
   at System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)
   at System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)
   at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, DataContract& dataContract)
   at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, DataContract dataContract, String name, String ns)
   at System.Runtime.Serialization.DataContractSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName)
   at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName)
   at System.Runtime.Serialization.XmlObjectSerializer.ReadObject(XmlDictionaryReader reader)
   at IdeaBlade.EntityModel.SerializationFns.RestoreDCS(Type instanceType, Stream stream, Boolean closeOnExit, IEnumerable`1 knownTypes, Boolean useBinaryFormat)
   at IdeaBlade.EntityModel.EntityMetadataStore.<>c__DisplayClass13.<LoadMetadataFromEmbeddedResources>b__10(String nm)
   at IdeaBlade.Core.EnumerableFns.ForEach[T](IEnumerable`1 items, Action`1 action)
   at IdeaBlade.EntityModel.EntityMetadataStore.LoadMetadataFromEmbeddedResources(Assembly assembly)
   at IdeaBlade.EntityModel.EntityMetadataStore.GetEntityMetadata(Type entityType)
   at IdeaBlade.EntityModel.EntityAspect.get_EntityGroup()
   at IdeaBlade.Aop.ProvideEntityAspect.GetEntityProperty(LocationInterceptionArgs args)
   at IdeaBlade.Aop.ProvideEntityAspect.PropertySetInterceptor(LocationInterceptionArgs args)





Replies:
Posted By: kimj
Date Posted: 21-Mar-2012 at 9:03am
We've seen quite a few problems with design time data once SL5 is installed.  Most of the problems are related to use of the DataContractSerializer, which is what DevForce is using to load the ibmmx metadata file.   We haven't seen this specific error before, so you might be able to move further along if you remove the AllowPartiallyTrustedCallers attribute from this assembly.
 
I should add that we've seen designer problems in applications targeting either SL4 or SL5 once SL5 is installed. 
 


Posted By: splace
Date Posted: 21-Mar-2012 at 12:12pm
The assembly is System.Runtime.Serialization, I don't think I can remove the AllowPartiallyTrustedCallers attribute. This application is targeting SL5 only.


Posted By: kimj
Date Posted: 21-Mar-2012 at 12:19pm
One other thing to try is to add the InternalsVisibleTo attribute to make your assembly internals visible to System.Runtime.Serialization.  Again, we haven't had good results with the serializer if SL5 is installed, but it could be worth a try.   DevForce will usually auto-generate this attribute into Code First model assemblies, but it could be missing.
 
[assemblyInternalsVisibleTo("System.Runtime.Serialization, PublicKey=00240000048000009400000006020000002400005253413100040000010001008d56c76f9e8649383049f383c44be0ec204181822a6c31cf5eb7ef486944d032188ea1d3920763712ccb12d75fb77e9811149e6148e5d32fbaab37611c1878ddc19e20ef135d0cb2cff2bfec3d115810c3d9069638fe4be215dbf795861920e5ab6f7db2e2ceef136ac23d5dd2bf031700aec232f6c6b1c785b4305c123b37ab")]



Print Page | Close Window