我使用以下代码从JavaScript调用C#方法:
C#:
geckoWebBrowser1.AddMessageEventListener("myEvent",
((string s) => this.showMessage(s)),true);
JS:
var event = new MessageEvent('myEvent',
{ 'view': window,
'bubbles': false,
'cancelable': false,
'data': 'some data' });
document.dispatchEvent(event);
当我使用x86构建(xulrunner和geckoFx)时,这非常有效,但是当我使用x64构建(xulrunner和geckoFx)时,我得到以下异常:
An exception of type 'System.NotImplementedException' occurred in
Geckofx-Core.dll but was not handled in user code
Additional information: The method or operation is not implemented.
StackTrace:
at Gecko.SpiderMonkey.JS_GetStringCharsAndLength(IntPtr cx, IntPtr jsString, UInt32& length)
at Gecko.AutoJSContext.ConvertValueToString(JsVal value)
at Gecko.JsVal.ToString() at Gecko.DomMessageEventArgs.get_Message()
at Gecko.GeckoWebBrowser.OnHandleDomEvent(DomEventArgs e)
in C:\Users\test\Desktop\GeckoFXsource31\Geckofx-Winforms\GeckoWebBrowser.cs:line 1982
at Gecko.GeckoWebBrowser.Gecko.nsIDOMEventListener.HandleEvent(nsIDOMEvent e)
in C:\Users\test\Desktop\GeckoFXsource31\Geckofx-Winforms\GeckoWebBrowser.cs:line 1878
有谁知道如何解决它或知道将我的数据从gecko传输到C#代码的另一种方法?