views:

205

answers:

2

I know that Entity Framework supports Partial trust, I personally blogged about that

It was working fine, I tested it and it was fine. Now if you download the samples attached to my post about the subject, it doesn't run under default partial trust anymore!!!

When I dug into System.Data.Entity assembly using reflector on the position of failure "System.Data.Objects.LightweightCodeGenerator.ValidateSetterProperty(RuntimeMethodHandle setterMethodHandle, MethodInfo& setterMethodInfo, Type& realType" I noticed that it calls RuntimeMethodHandle.Value property which has the following attribute on get accessor "[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode=true)]"

So I went to my medium trust configuration and added another flag "UnmanagedCode" ""

I test the application again and it worked fine.

Now what is this all about?! It was working before so why now not it is not! There is something missing!!! Does System.Data.Entity changed during the several frequent updates post to of VS.NET 2008 SP1 and the latest one was made on Last August 2009. Because before that date, it was working fine.

So I would appreciate if any could clarify this and guide me if I am wrong, or there is something that I am missing.

+1  A: 

It sounds like you have definitive proof of a breaking change to Entity Framework. I would go to http://connect.microsoft.com/ and report a bug. It would probably help if you could confirm that a change was made by finidng the old assembly without the "UnmanagedCode=true" attribute. Include both versions in the bug report.

Incidentally, I just looked at RuntimeMethodHandle in Reflector. The get accessor for Value returns "this.m_ptr;" and has no attribute decorations. It's in mscorlib, my version is 2.0.0.0 (I'm running .NET 3.5 on my development system.)

Dave Swersky
Will do that. good idea thanks for the link
mosessaur
+1  A: 

Diego Vega PM in Entity Framework team responded to this issue in Entity Framework forums with the following

Hello Muhammad,

We are aware of an issue in the build included in Windows 7 and Windows Server 2008 R2 that prevents Entity Framework from working in Medium Trust.

Both the version of mscoree.dll and the exception message you describe match the scenario.

We expect to have a solution before mainstream adoption of Windows 7 and Windows Server 2008 R2, but in the meanwhile the recommendation is to keep using Windows Server 2008 or Windows Vista for testing and deploying of EF based applications in Medium Trust.

Hope this helps, Diego

mosessaur