Reputation: 43
I'm using GeckoFX 29.0 with AutoJSContext and when i launch my app, it gives me the following error :
Xpcom.Initialize must be called before using of any xulrunner/gecko-fx services
I understand that i must initialize Xpcom before calling AutoJS but in my code XPcom(xullrunner) is initialize before the Sub named "GeckoFxError"
Sub New()
InitializeComponent()
Gecko.Xpcom.Initialize(Environment.CurrentDirectory + "/xulrunner")
Gecko.GeckoPreferences.Default("extensions.blocklist.enabled") = False
Timer1.Enabled = True
End Sub
Sub New1()
Dim _memoryService = Xpcom.GetService(Of nsIMemory)("@mozilla.org/xpcom/memory-service;1")
_memoryService.HeapMinimize(False)
End Sub
Private Sub GeckoFXerror(sender As Object, e As Gecko.JavascriptErrorEventArgs) Handles GeckoWebBrowser1.JavascriptError
Dim text As String = "window.alert = function(){};"
Dim text2 As String = "window.confirm = function(){};"
Dim text3 As String = "window.open = function(){};"
Dim text4 As String = "window.prompt = function(){};"
Using context As AutoJSContext = New AutoJSContext(GeckoWebBrowser1.Window.JSContext)
Dim result As String = ""
context.EvaluateScript(text, result)
End Using
Using context As AutoJSContext = New AutoJSContext(GeckoWebBrowser1.Window.JSContext)
Dim result As String = ""
context.EvaluateScript(text2, result)
End Using
Using context As AutoJSContext = New AutoJSContext(GeckoWebBrowser1.Window.JSContext)
Dim result As String = ""
context.EvaluateScript(text3, result)
End Using
Using context As AutoJSContext = New AutoJSContext(GeckoWebBrowser1.Window.JSContext)
Dim result As String = ""
context.EvaluateScript(text4, result)
End Using
End Sub
Thanks for your help and i think it's easy to solve but i haven't found any solution in more than one hour
Upvotes: 0
Views: 459
Reputation: 891
Put your Gecko.Xpcom.Initialize(Environment.CurrentDirectory + "/xulrunner")
before calling InitializeComponent()
and it should work.
Upvotes: 1