Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Operation could destabilize the runtime: LinqToSQL

Despite this being one of the best error messages I've ever seen (second only to, "This operation could destabilize the rent in the space-time continuum"), it's also one of the most frustrating.

I have developed an ASP.NET MVC site which works perfectly through VS2008. It works perfectly hosted on a local IIS7 server (Win2008Server & Win7beta), and also on another Win2008Server host. A few days ago, I uploaded the site to a new host (Win2008Server), and have run into the "Operation could destabilize the runtime" error whenever one (and only one) of my LinqToSQL statements is evaluated.

The Linq statement in question has been simplified to the point of obscurity, and still whenever I evaluate the result the error occurs:

var result = from e in db.calendarEvents select e;
foreach (var event in result)  // error occurs on this line
{
    ...
}

The remote host in question is running in full trust, and there are no switch statements in sight (these two issues came up on Google as being related to the error).

A similar issue was reported at Operation could destabilize the runtime?, but there are no interfaces used (that I am aware of).

Any ideas?

--- Just a pause: The table in question uses a TIME data type, and maps to a TimeSpan property. Apparently this was only available in .NET 3.5 SP1. I'm waiting to find out if my new host has SP1 installed...

like image 565
Darren Oster Avatar asked Jan 27 '09 00:01

Darren Oster


2 Answers

OK, the end result was that my host was running my site on a server with .NET 3.5 installed (not SP1), and the one table that used the TIME SQL datatype broke with the above error. http://msdn.microsoft.com/en-us/library/bb386947.aspx states that LINQ to SQL supports mapping of these new types starting with .NET 3.5 SP1.

My host kindly migrated my site to a .NET 3.5 SP1 server, and all is good.

like image 89
Darren Oster Avatar answered Nov 12 '22 08:11

Darren Oster


event is a keyword. Use @event for your variable name instead.

like image 34
Amy B Avatar answered Nov 12 '22 10:11

Amy B