4

I'm having a problem in an ASP.NET C# MVC project that we're doing.

We're using .NET Framework 4.0 for the development, and recently I upgraded my Visual Studio to 2012 (everyone else is using 2010), and now it stopped working. Now in some places I get the error:

Operation could destabilize the runtime.

I've found some people saying that this has to do with .NET 4.5 being installed with Visual Studio 2012, but I didnt find a solution for my problem yet. The line in code it complains about looks like this:

var companyModel = from c in db.Company select c;
return View(companyModel.ToPagedList(page, 10));

Whats wrong about this code? companyModel become a

System.Linq.IQueryable<Company>

I tried adding

companyModel.OfType<Company>();

Between these 2 lines, but it didnt work either (idea from Operation could destabilize the runtime?)

Everything works just fine with Visual Studio 2010. Thanks!

Community
  • 1
  • 1
Johan Svensson
  • 863
  • 3
  • 9
  • 23

2 Answers2

3

Get the latest version of PagedList, that should fix it. I had the same problem.

Joe Ratzer
  • 18,176
  • 3
  • 37
  • 51
0

What you've heard is correct, installing VS2012 installs .Net 4.5 which overlays .Net 4.0. If you have done no other windows updates (i.e. .Net 4.5 updates) this might be related to a bug in the framework.

See this hotfix: http://support.microsoft.com/kb/2748645

The updated 3rd party code likely utilizes one of the work arounds.

You might want to read up on peoples woe's with .Net 4.5 being an inplace upgrade to .Net 4.0. And if your entire team isn't upgrading to VS2012 (and you are targeting .Net 4.0 framework) you may want to consider rolling back your machine and not upgrading past VS2010.

It may not apply to your MVC app, but be cautious if you develop any applications for client environments now that you have .Net 4.5. Regardless of what Visual Studio is telling you, you no longer "target" .Net 4.0.

How to keep .Net 4.0 behavior if .Net 4.5 is installed?

Is it possible to run a .net 4.5 app on XP?

Visual C# Breaking Changes in Visual Studio 2012

Community
  • 1
  • 1
Arkaine55
  • 548
  • 6
  • 15