title: What is wrong with this dynamic code execution?
body: <p>I have this code:</p>
  <pre><code>var code = @&quot;public class Abc { public string Get() { return &quot;&quot;aaaaaaaaaa&quot;&quot;; }}&quot;;
  var options = new CompilerParameters();
  options.GenerateExecutable = false;
  options.GenerateInMemory = false;
  
  var provider = new CSharpCodeProvider();
  var compile = provider.CompileAssemblyFromSource(options, code);
  
  var type = compile.CompiledAssembly.GetType(&quot;Abc&quot;);
  var abc = Activator.CreateInstance(type);
  
  var method = type.GetMethod(&quot;Get&quot;);
  var result = method.Invoke(abc, null);
  ut = result.ToString();
  </code></pre>
  <p>the variable <em>code</em> in this case gets executed correctly, but if I do something different like:</p>
  <pre><code>var code = @&quot;using System; public class Abc { static string Get() { return System.DateTime.Now}}&quot;;
  </code></pre>
  <p>It does not get executed and gives me the following error: <em>Could not load file or assembly 'file:///C:\Windows\TEMP\504kbl2w.dll' or one of its dependencies. The system cannot find the file specified</em></p>
  <p>Why does it happen? How can I fix it?</p>