title: C# How to debug methods called by Invoke()
body: <p>I am trying to debug a method in a dynamically created instance of a class:</p>
  
  <pre><code>test = (Class1) Activator.CreateInstance(type);
  test2 (List&lt;string&gt;)test.GetType().GetMethod("DoSomething").Invoke(test,arguments);                 
  </code></pre>
  
  <p>I've tried to put in the dynamically invoked method the following:</p>
  
  <pre><code>#if DEBUG
              System.Diagnostics.Debugger.Break();
  #endif
  </code></pre>
  
  <p>In "DoSomething" method, but nothing seems to work :(. Debugger is not being called in this dynamically created instance of a class.</p>
  
  <p>P.S. I am compiling the file at runtime (reading class files and then using CodeDomProvider.CreateProvider("CSharp") and CompilerParameters + CompileAssemblyFromSource). Maybe there are some parameters to activate debugging there? Thanks!!!</p>