Microsoft LINQ Books

Programming Microsoft LINQ & Introducing Microsoft LINQ
Welcome to Microsoft LINQ Books Sign in | Join | Help
in Search

Marco Russo

VerificationException

Writing the upcoming Programming Microsoft LINQ book, I encountered the following issue in LINQ to SQL.

The Link<T> generic type is part of the deferred loading system for LINQ to SQL entities (it allows to defer the loading of a property, while EntityRef<T> works at an entity level). Link<T> is intended to be the type for a storage member used by a property of type T. In a fast demo, I forgot this and I used the Link<T> type directly as the type for a public data member.

public [Column] Link<string> Address;

This is an error that cannot be intercepted at compile time but that will throw an exception during execution. With the .NET Framework 3.5 RTM, this throws a VerificationException with the following message:

System.Security.VerificationException: Operation could destabilize the runtime.

I was initially scared of the destructive power of my error. Luckily, Dinesh Kulkarni was kindly enough to explain me the reason:

[...]You need a member of a primitive type understood by the query translator. In your example, the Link<T> member is not understood.[...]

Of course, the exception message can be improved. I opened an issue on Connect and I hope that this blog entry will help who will encounter this same issue in the future.

Published martedì 5 febbraio 2008 18.19 by Marco.Russo

Comments

No Comments
Anonymous comments are disabled
Powered by Community Server (Personal Edition), by Telligent Systems