Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3228280
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:40:25+00:00 2026-05-17T16:40:25+00:00

I have the following code: Dim compiler As ICodeCompiler = New Microsoft.JScript.JScriptCodeProvider().CreateCompiler Dim params

  • 0

I have the following 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))

Trying to compiler the folowing JavaScript code:

class Foo {

    function FindProxyForURL(url, host) 
        {
            alert('Test')
            return "PROXY myproxy.local:8080";
        }
}

And getting an error on –

 compiler.CompileAssemblyFromSource(params, TextBox1.Text.Trim)

{C:\Users\Me\AppData\Local\Temp\zfwspah4.0.js(4,65)
: error JS1135: Variable ‘alert’ has
not been declared}

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.

How can i fix this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T16:40:26+00:00Added an answer on May 17, 2026 at 4:40 pm

    alert is a function supplied by some host environments (for instance, browsers have it, but servers probably don’t). Changing from alert to window.alert didn’t make any difference because (on a browser) it comes to the same thing. (window is a property of the global object that refers back to the global object. alert is a property of the global object that refers to a host-provided function. So window.alert is the same as alert is the same as window.window.window.alert. But I digress…)

    You’ll have to use (and probably import, or receive as a function parameter, etc.) whatever mechanism is provided by the host environment in which you’re going to run your compiled JavaScript.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code to convert a distinguishedName to a sAMAccountName: Dim de
I have the following code in Visual Studio 2005. Dim OutFile As System.IO.StreamWriter Try
In VB6 code, I have the following: dim I as Long I = Weekday(Now,
I have the following code: $bind = new COM(LDAP://CN=GroupName,OU=Groups,OU=Division,DC=company,DC=local); When I execute it from
I have the following (simple) VB6 code: Dim xmlDoc As MSXML2.DOMDocument30 Set xmlDoc =
Let's say I have the following code: Sub TestRangeLoop() Dim rng As Range Set
I have the following code that returns 50 random color-coded numbers: Sub RandomNumberColor() Dim
In an MS-Access form, I have the following code attached to an event: Dim
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
I have following Code Block Which I tried to optimize in the Optimized section

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.