C # asp.net operation can destabilize runtime

I had a problem in an ASP.NET C # MVC project that we are doing.

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

Operation could destabilize the runtime. 

I found some people saying that this is due to installing .NET 4.5 with Visual Studio 2012, but I have not yet found a solution for my problem. The line in the code she complains about is as follows:

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

What is wrong with this code? companyModel will become

 System.Linq.IQueryable<Company> 

I tried adding

 companyModel.OfType<Company>(); 

Between these two lines, but it didnโ€™t work either (idea from Operation can destabilize runtime? )

Everything works fine with Visual Studio 2010. Thank you!

+4
source share
2 answers

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

+3
source

What you heard is correct, installing VS2012 installs .Net 4.5, which imposes .Net 4.0. If you have not done any other Windows updates (i.e. .Net 4.5), this may be due to a framework error.

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

The updated third-party code probably uses one of the workstations.

You might want to read about the people with whom .Net 4.5 is updating inplace to .Net 4.0. And if your entire team is not upgrading to VS2012 (and you are targeting .Net 4.0 infrastructure), you may need to roll back your machine, rather than updating VS2010.

This may not apply to your MVC application, but be careful if you already have applications for .Net 4.5 client environments. No matter what Visual Studio tells you, you're no longer targeting .Net 4.0.

How to save .NET 4.0 behavior if .Net 4.5 is installed?

Is it possible to run .net 4.5 application on XP?

Visual C # Breaking Changes in Visual Studio 2012

0
source

Source: https://habr.com/ru/post/1435866/


All Articles