Related Tags:
C# C# (pronounced "C-sharp") is an object-oriented programming language from Microsoft that aims to combine the computing power of C++ with the programming ease of Visual Basic. C# is based on C++ and contains features similar to those of Java. Learn More, Microsoft Visual Studio Microsoft Visual Studio is an integrated development environment (IDE) from Microsoft. It is used to develop computer programs for Microsoft Windows, as well as web sites, web apps, web services and mobile apps. Learn More, ASP.NET MVC The ASP.NET MVC framework is a lightweight, highly testable presentation framework that (as with Web Forms-based applications) is integrated with existing ASP.NET features, such as master pages and membership-based authentication. The MVC framework is defined in the System.Web.Mvc assembly. Learn More,

Cannot evaluate expression because the code of the current method is optimized

Description:I have noticed that from last few days I am started getting "Cannot evaluate expression because the code of the current method is optimized" error in my visual studiio 2017 project , I have no idea is there any visual studio setting that is needed to be updated or it is due to my project implementation ?

Posted by: | Posted on: May 30, 2019

2 answers



First of all one thing is for sure that this error's nothing to do with Visual studio Version , now there are few things which you need to check to resolve this error as follows.

1)Make sure your project and solution are running in debug mode.

2)Make sure you have unchecked the Optimize Code property under project properties. Project (right Click)--> Properties --> Build (tab) --> uncheck Optimize code

3)Make sure you have enabled Use managed compatibility mode option. by going to : Tools --> Options --> Debugging --> General -->Use managed compatibility mode

4)Once Clean and rebuilt your solution.

Replied by: | Replied on: May 30, 2019


Works. Thank you very much!

Replied by: | Replied on: Dec 12, 2019


Code block Hyperlink bold Quotes block Upload Images