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

Commented Unassigned: cross-engine nested exception fault [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: Hmm, we're seeing somewhat different behavior. The exception is delivered correctly to the managed caller (as an instance of `ScriptEngineException` with the correct message string), but the failing cross-engine calls are being executed twice, yielding not two but _four_ "begin-bmethod" traces (because `binvoke` is executed twice). We've investigated this briefly and it appears to be due to COM interop bug in the .NET framework. We're looking for a workaround. Thanks for reporting this issue!

Viewing all articles
Browse latest Browse all 2297

Latest Images

Trending Articles





Latest Images