Q:

getting runtime error assembly 'System.Runtime' while using CSharpCodeProvider

I'm getting runtime error about missing reference.

The type 'System.Object' is defined in an assembly that is not
  referenced. You must add a reference to assembly 'System.Runtime,
  Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

I'm using MVC application and used CSharpCodeProvider inside my code.
I do not get any compile error but getting runtime error for compileResult as above why?
 CompilerResults results = provider.CompileAssemblyFromSource(parameters, code);

I even added assemblies tag in web.cofig like following still same error.any clue why?
  <assemblies>     
    <add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />   
  </assemblies>

A:

ASP.NET MVC uses the dynamic keyword a lot. That may be the original of the problem, since that requires both the Microsoft.CSharp assembly (which you have obviously included) and the System.Runtime assembly (I think this one is missing.
Add the System.Runtime assembly in your compile config:
parameters.ReferencedAssemblies.Add("mscorlib.dll"); // guess you have this one already
parameters.ReferencedAssemblies.Add("System.Runtime.dll");

