Dynamic in the immediate window causes 'Microsoft.CSharp.RuntimeBinder.Binder' is not defined or imported error

Colonel Panic picture Colonel Panic · Nov 26, 2012 · Viewed 50.1k times · Source

If I use dynamic in the immediate window of Visual Studio I get an error

Predefined type 'Microsoft.CSharp.RuntimeBinder.Binder' is not defined or imported

How can I fix that?

Answer

HoberMellow picture HoberMellow · Nov 26, 2012

You should add reference to Microsoft.CSharp library in the selected project or in the startup project. And your project should reference .NET Framework 4 or higher.

MSDN about immediate window context:

When establishing the context for design time expression evaluation, Visual Studio references the currently selected project in Solution Explorer. If no project is selected in Solution Explorer, Visual Studio attempts to evaluate the function against the startup project. If the function cannot be evaluated in the current context, you will receive an error message.