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

Commented Issue: [FIXED] Double execution of cross-engine VBScript calls that throw exceptions [108]

0
0
got one more cross-engine issue.

an error raised by scriptengine (b) which was invoked by another scriptengine (a), doesn't make it to scriptengine (a) and properly back to the origin calle in the stack scriptengine (b). which means the script execution error occurred as such in scriptengine (b) cant be catched by a try-catch on the host side.

on more weird issue happening along side is that the code block (function|sub) where the error was raised gets executed from the very beginning.

in short the call chain looks like this:
```
engineA.someMethod(
engineB.anotherMethod(
engineA.errorOccuringMethod(
- firstLineCode -
someErrorCode -> causing a rerun of engineA.errorOccuringmethod() then throwing COMException in WindowsScriptEngine.ThrowHostException()
)
)
)
```

here a sample code:

```
var seA = new VBScriptEngine();
seA.Script.WriteLine = new Action<string>((text) => Console.WriteLine(text));
seA.Execute(@"
class aclass

function binvoke(bobj)
bobj.bmethod()
end function

end class
dim avar : set avar = new aclass
");

var seB = new VBScriptEngine();
seB.Script.WriteLine = new Action<string>((text) => Console.WriteLine(text));
seB.Execute(@"
class bclass

function bmethod()
WriteLine(""begin-bmethod"")
err.raise 1, ""source"", ""errdescr""
bmethod = ""retval""
WriteLine(""end-bmethod"")
end function

function go(seA, bobj)
dim i
'for i = 0 to 5
seA.binvoke(bobj)
'next
end function

end class
dim bvar : set bvar = new bclass
");


try
{
seB.Script.bvar.go(seA.Script.avar, seB.Script.bvar);
}
catch (System.Runtime.InteropServices.COMException)
{
throw;
}
catch (Exception)
{
throw;
}
```

you should see 2xtimes "begin-bmethod" in the console output before the debugger stop at WindowsScriptEngine.ThrowHostException()

the expected behaviour would be 1xtime "begin-bmethod" in the console output and break of the debugger in the try-catch block
Comments: Fixed in [Version 5.4.6](https://clearscript.codeplex.com/SourceControl/changeset/a453fe935c7f30b8285ca6d9a34bf2165b4b7805).

Viewing all articles
Browse latest Browse all 2297

Latest Images

Trending Articles





Latest Images