Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: Problem Calling VBScript Function

0
0
I have a very simple app at this time. I am developing in VB.NET (CLR 4.5) and using the VBScript Engine. My application is to be used for industrial process simulations so my .Net application will call the same script method (Sub Main) roughly every second. The code in VB.Net looks like this.
  engine.Script.Main()
In VBScript
Public Sub Main()
  Dim x
  x = 5
End Sub
Right now I am just using a button to test this. The first time I click the button, I Execute the entire script
  engine.Execute(ScriptText)
On subsequent button pushes I call Main
  engine.Script.Main()
And I get the following error

"Exception has been thrown by the target of an invocation."

I have found that the following works fine however I read a post here that recommends against invoking script this way for performance reasons. Because my application will likely call many different Sub Main() scripts every second, performance will be very important.
  engine.Execute("Main")
I have stripped this down as much as possible and still can't get it to work as recommended - any suggestions?

Viewing all articles
Browse latest Browse all 2297