Click to See Complete Forum and Search --> : Embedding Mozilla in c#: Browser is not in a valid state


EricBlair
04-01-2007, 09:15 AM
Hi,

New to mozilla embedding. In .Net C# I have an app that loads the
browser when I place it in a new form and it runs.

But I want to load the browser as a Browser (in the native browser
window) when I try to do this:

AxMozillaBrowser BrowserApp=new AxMozillaBrowser();
BrowserApp.Navigate("http://www.somesite.com");

I get this error:
Exception of type 'System.Windows.Forms.AxHost
+InvalidActiveXStateException' was thrown.

If I try this:
MozillaBrowser BrowserApp=new MozillaBrowser();
BrowserApp.Navigate("http://www.somesite.com", ref o, ref o, ref o,
ref o);

I get this error:
Browser is not in a valid state

System.Runtime.InteropServices.COMException was unhandled
Message="Browser is not in a valid state"
Source="Mozilla.Browser.1"
ErrorCode=-2147418113
StackTrace:
at MOZILLACONTROLLib.MozillaBrowserClass.Navigate(String URL,
Object& Flags, Object& TargetFrameName, Object& PostData, Object&
Headers)
at SimpleBrowser.SimpleBrowser.Main() in C:\MozBrowser
\MozBrowser.cs:line 30
at System.AppDomain.nExecuteAssembly(Assembly assembly,
String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile,
Evidence assemblySecurity, String[] args)
at
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object
state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

I must be missing some initialization call, I don't what it is.

Anyone here done this successfully and have any tips?

Thanks!
Reply With Quote

Cstick
04-01-2007, 11:31 PM
Have you tried command line? Something like this...

Dim p As Process = Process.Start("firefox.exe", """www.webdeveloper.com""")
System.Threading.Thread.Sleep(5000)
p.Refresh()
If Not p.HasExited Then
p.CloseMainWindow()
p.Close()
End If

EricBlair
04-02-2007, 03:24 PM
Yup. I know I can do that. But that's a different issue. I want to run the mozilla embed.