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?
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.
Two things are important. Check the following:
Afterwards you can use the dynamic
type. The reference needs to be added in the selected project or in the startup project in order to become available in the immediate window's scope.
Note: Here I found a nice article about dynamics in C#, how it works and what you can do with it.
Happy coding!
Namespace: Microsoft.CSharp.RuntimeBinder
Assembly: Microsoft.CSharp (in Microsoft.CSharp.dll)
Example
http://stepbystepdotnet.wordpress.com/2012/08/06/predefined-type-microsoft-csharp-runtimebinder-binder-is-not-defined-or-importedtestproject1/
http://msdn.microsoft.com/en-us/library/microsoft.csharp.runtimebinder.binder%28v=vs.110%29.aspx
http://msdn.microsoft.com/en-us/library/microsoft.csharp.runtimebinder%28v=vs.110%29.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With