Dynamic in the direct window calls "Microsoft.CSharp.RuntimeBinder.Binder" is not detected or error is not imported

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

The predefined type "Microsoft.CSharp.RuntimeBinder.Binder" is not defined or imported

How can i fix this?

+60
c # dynamic visual-studio immediate-window
Nov 26
source share
4 answers

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

MSDN about the immediate window context:

When creating a context for evaluating a development-time expression, Visual Studio refers to the currently selected project in the Explorer solution. If no project is selected in Solution Explorer, Visual Studio tries to evaluate the function against the launch project. If the function cannot be evaluated in the current context, you will receive an error message.

+103
Nov 26
source share

Two things are important. Check the following:

  • That your project properties refer to the .NET Framework 4 or higher (if it is not, change it: right-click on the project, select the "Properties ..." menu item, then select ".NET Framework 4" as the target environment (or higher).
  • To add the Microsoft.CSharp link as a link (note that step 1., which requires a reboot of the project, must be completed before you can do this)

Subsequently, you can use the dynamic type. The link must be added to the selected project or launch project in order to be available in the immediate window area.

+16
Feb 11 '14 at 16:29
source share
  • Go to project-> add link.
  • select assemblies from sidebar and Framework
  • check out Microsoft.CSharp

Happy coding!

+7
Apr 10 '15 at 6:13
source share



All Articles