title: Public variable interference between InMemory generated assemblies from CodeDom
body: <p>Users are able to launch multiple instances of InMemory assemblies from a main application.
  The problem is the public variables in the InMemory assemblies seem to overwrite each other. Is there a way to fix this?</p>
  
  <p>I also tried renaming the Namespace Evaluator and Class Evaluator to differently per instance but that did not help.</p>
  
  <pre><code>Namespace Evaluator
  
      Public Module GlobalSettings
          Public Var1 As String
          Public Var2 As String
          Public TextBox1 As New TextBox
          Public TextBox2 As New TextBox
      End Module
  
      Public Class Evaluator
  
          '...insert code here
  
      End Class
  
  End Namespace
  
  Friend Function CompileCode() As Object
      Dim compResults As CompilerResults
      Dim code = GetCode()
  
      Dim provOptions As New Dictionary(Of String, String)
      provOptions.Add("CompilerVersion", "v3.5")
  
      Dim vbProv = New VBCodeProvider(provOptions)
  
      Dim vbParams = New CompilerParameters()
      vbParams.ReferencedAssemblies.Add("mscorlib.dll")
      vbParams.ReferencedAssemblies.Add("System.dll")
      vbParams.ReferencedAssemblies.Add("System.Windows.Forms.dll")
      vbParams.ReferencedAssemblies.Add("Microsoft.VisualBasic.dll")
      vbParams.ReferencedAssemblies.Add("System.Data.dll")
  
      vbParams.TreatWarningsAsErrors = False
      vbParams.GenerateExecutable = False
      vbParams.GenerateInMemory = True
  
      compResults = vbProv.CompileAssemblyFromSource(vbParams, code)
  
       _evaluator = compResults.CompiledAssembly.CreateInstance("Evaluator.Evaluator")
  
  End Function
  </code></pre>