C# – How to add `System.Dynamic` to the project

c#-4.0c++dynamic-language-runtime

I am new to C# 4, especially the dynamic keyword. I have seen quite a number of tutorials and wish to try it out myself using VS 2012 Ultimate (MSDN).

Unfortunately I cannot seem to find System.Dynamic and cannot add a reference to it either. May I know where I can find the DLL for System.Dynamic and what I might have done wrong?

By default, VS 2012 already targets Fx 4.5, and System.Core is added as a reference.

The dynamic keyword is so common that when searching in Google yield a lot of un-related results.

Best Solution

  1. Make sure you are targeting the .NET Framework version 4 or later.

  2. Ensure your project references the System.Core assembly.

  3. You will find the types and functionality of System.Dynamic in that assembly. Add the following line to your code files:

    using System.Dynamic;
    

<code>System.Dynamic</code> is found in <code>System.Core.dll</code>

P.S.: In C#, in order for the dynamic keyword to work properly, you also need to reference the Microsoft.CSharp assembly. This assembly contains the late-binding functionality necessary for dynamic.