EntityFramework: VerificationException - Operation could destabilize the runtime.
-
Tuesday, May 15, 2012 1:12 PM
Hello,
When I deployed my code to IIS 7.5 on Windows Server 2008 R2 I got the following exception I did not see on my developer pc:
VerificationException - Operation could destabilize the runtime.
The stack trace showed this happened while trying to resolve a particular type from my Unity container.
I'm not sure I did not see this earlier on my developer pc.
As I googled for this error I read somebody recommend I run PEVerify on my dlls. My Opralog.Web.dll passed. But my Opralog.Common.Web.dll failed saying:
Microsoft (R) .NET Framework PE Verifier. Version 4.0.30319.1
Copyright (c) Microsoft Corporation. All rights reserved.[MD]: Warning: Class does not implement interface method in this module (class:0x0200000f; interface:0x02000005; method:0x06000015). [token:0x09000006]
[MD]: Warning: MemberRef has a duplicate, token=0x0a000091. [token:0x0A000090]
[MD]: Warning: MemberRef has a duplicate, token=0x0a000090. [token:0x0A000091]
[IL]: Error: [C:\Users\rblok\Documents\visual studio 2010\Projects\Opralog\Opralog.Common.Web\bin\Debug\Opralog.Common.Web.dll : Opralog.Common.Web.DomainContext::AttachAsModified[T]][mdToken=0x600005b][offset 0x0000000A] Unable to resolve token.
1 Error(s) Verifying C:\Users\rblok\Documents\visual studio 2010\Projects\Opralog\Opralog.Common.Web\bin\Debug\Opralog.Common.Web.dll
(3 Warnings)I see it complains about my Opralog.Common.Web.DomainContext class, which derives from DbContext, specifically a method called AttachAsModified. Although there appears to be no other relationship with the particular class that was being resolved from my Unity container except that they live inthe same assembly.
Anyway, here is the source code:
public void AttachAsModified<T>(T current, T original) where T : class { this.Set<T>().AttachAsModified(current, original, this); }This AttachAsModified method is an extension method in a static class called System.ServiceModel.DomainServices.EntityFramework.DbContextExtensions which is in a WCF RIA Services assembly called Microsoft.ServiceModel.DomainServices.EntityFramework.dll.
I thought the explanation would be that my Opralog.Common.Web.dll references EF 4.3.1, whereas Microsoft.ServiceModel.DomainServices.EntityFramework.dll references EF 4.1, for which I had to include the following binding redirect in my web.config file.
<runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.3.1.0" newVersion="4.3.1.0" /> </dependentAssembly> </assemblyBinding> </runtime>So I got annoyed again at the WCF RIA Services team for not updating their support from EF 4.1 to EF 4.3.1. But while I had my command prompt open I ran PEVerify on Microsoft.ServiceModel.DomainServices.EntityFramework.dll, which passed. Then I ran PEVerify on EntityFramework.dll version 4.3.1 and I got 494 warnings. What's all that about???
Microsoft (R) .NET Framework PE Verifier. Version 4.0.30319.1
Copyright (c) Microsoft Corporation. All rights reserved.[MD]: Warning: MemberRef has a duplicate, token=0x0a00076f. [token:0x0A000003]
..........
[MD]: Warning: MemberRef has a duplicate, token=0x0a0008ed. [token:0x0A000C8C]
All Classes and Methods in C:\Users\rblok\Documents\visual studio 2010\Projects\Opralog\Opralog.Common.Web\bin\Debug\EntityFramework.dll Verified.
(494 Warnings)- Edited by Remco Blok Tuesday, May 15, 2012 1:28 PM
- Moved by Cathy Mi - MSFTMicrosoft Employee Wednesday, May 23, 2012 3:42 PM (From:ADO.NET Entity Framework and LINQ to Entities)
All Replies
-
Wednesday, May 16, 2012 9:33 AM
EF 5.0 rc produces similar warnings in PEVerify: just a few more: 503 in total.
-
Thursday, May 17, 2012 2:39 AM
Hi Remco Blok,
Welcome to MSDN Forum.
We will do some more pending research about your problem and come back as soon as possible, Thanks for understanding.
Have a nice day.
Allen Li [MSFT]
MSDN Community Support | Feedback to us
-
Wednesday, May 23, 2012 3:48 PMI just got notified that this post was moved from the Entity Framework forum to the WCF forum. Can Microsoft provide an update on their research please?

