[Solved] Internal error evaluating expression C#



internal error evaluating expression



A quick fix on the Internal error evaluating expression this article describes a step-by-step guide with an image.   

In this article, I cover the root cause of "Internal error evaluating the expression". If you are new to IDE Visual Studio either 2015, 2017, or 2019 the show stopper while development is unavoidable.

Let's get started !


What is covered?
  • How did I encounter this error?
  • This is how I solved it
  • Summary


 How did I encounter this error?

To highlight the story behind this,

The requirement is to create a COM object that interacts with the FoxPro application that can not support advanced services in today's needs.  So the limited services provided  by the FoxPro extends the support  COM Application  that is developed in  DotNET Framework 4.5  

With the above requirement, I initiate development stages;

The next step is to choose IDE for developing COM applications which is a Class Library in  Visual Studio 2019   installed a VS 2019 successfully.  Most of the default settings are pre-defined by the Microsoft VS installer.  

I created a new class library and set the framework version to  DotNET Framework 4.5 

Started coding, where I created a dictionary collection to add decimal key-value pair, the key-value pair has been initialized with values.

Now try to run the application,  The real challenge comes here as the below image underlined the warning message.

Internal Error Evaluating an expression

 

Internal error evaluating expression


What happened to the values I initialized?  something went wrong or lost the values?

How come my compiler did not prompt before running the application?


This is how it is resolved

With all the questions asked,  it is that some of the legacy default settings were not enabled for Visual Studio 2019 after you installed it. 

Go to Visual Studio 2019  Tools Menu Options  and tick the legacy section settings   Enable fast express evaluation (Managed Only) 


Visual Studio 2019 Options


Save the settings, Compile the program and build it.

This is how I ensured the result is correct,  the same dictionary collection has values in it.

solved - Internal error evaluating expression


This brought me a smile rest of the day.

Summary

This is a very simple step-by-step guide article, maybe in another article, I elaborate from scratch on how to develop a COM Application in C# that interacts with other applications.

But for now, here to summarize the reason or root cause for C# error "Internal error evaluating the expression" and ticked legacy evaluating the expression in Tools > Options saved the settings.

Finally compiled the project and saw the result of the key-value pair image.

Visual Studio Value cannot be null Connection String has been solved

This is how solved creating unique class instance runtime C#

How to implement Distributed Cache Redis ASP.NET Core?