我使用 COM Interop 编写了一个 C# ActiveX 控件,以便公开方法 / 属性。
[ComVisible(true)]
class COMClass:ICOMClass
{
public string methodA()
{
string str = "abc";
if(str != "abcd")
throw new Exception("invalid string");
return str;
}
}
[ComVisible(true)]
interface ICOMClass
{
string methodA();
}
有没有办法在javascript中处理从C#抛出的异常?我已经找了很久,但是找不到任何信息。
例如:
var x = new ActiveXObject("COMClass");
try{
x.methodA
}
catch(e) {
alert(e);
}