title: Javascript Compiler in .Net giving errors
body: <p>I have the following code:</p>
  
  <pre><code> Dim compiler As ICodeCompiler = New Microsoft.JScript.JScriptCodeProvider().CreateCompiler
        Dim params As New CompilerParameters
        params.GenerateInMemory = True
  
        Dim res As CompilerResults = compiler.CompileAssemblyFromSource(params, TextBox1.Text.Trim)
        Dim ass As Assembly = res.CompiledAssembly
        Dim instance As Object = Activator.CreateInstance(ass.GetType("Foo"))
  
        Dim thisMethod As MethodInfo = instance.GetType().GetMethod("FindProxyForURL")
        Dim str(1) As String
        str(0) = ""
        str(1) = ""
  
  MessageBox.Show(thisMethod.Invoke(instance, str))
  </code></pre>
  
  <p>Trying to compiler the folowing JavaScript code:</p>
  
  <p>class Foo {</p>
  
  <pre><code>    function FindProxyForURL(url, host) 
          {
              alert('Test')
              return "PROXY myproxy.local:8080";
          }
  }
  </code></pre>
  
  <p>And getting an error on -</p>
  
  <pre><code> compiler.CompileAssemblyFromSource(params, TextBox1.Text.Trim)
  </code></pre>
  
  <blockquote>
    <p>{C:\Users\Me\AppData\Local\Temp\zfwspah4.0.js(4,65)
    : error JS1135: Variable 'alert' has
    not been declared}</p>
  </blockquote>
  
  <p>If i remove the "alert" line it works fine.
  I gather this is because alert is a "window" object, so .Net doesn't recognise it. I have tried replacing it with window.alert('')
  but still get the same error.</p>
  
  <p>How can i fix this?</p>