IE.Browser.Navigate(...) throws COMException

Add-in Express™ Support Service
That's what is more important than anything else

IE.Browser.Navigate(...) throws COMException
 
christianbpedersen




Posts: 34
Joined: 2009-07-19
Hi!

I've added a CommandItem to Internet Explorer 8, and when I click that CommandItem, I'm asking IE to navigate to a certain URL. However, the fails with the following information:

Exception Source: Interop.SHDocVw
Exception Type: System.Runtime.InteropServices.COMException
Exception Message: The requested resource is in use. (Exception from HRESULT: 0x800700AA)
Exception Target Site: Navigate

Even though the IEApp object has the property busy == true, the browser isn't doing anything, and the URL is about:blank.

This used to work in IE6 and IE7, but here it fails in IE8. Do I need to do something in particular when dealing with IE8, compared to IE7 and 6?

Best regards,
Christian
Posted 10 Feb, 2010 05:11:18 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Christian.

I have just tested the IEApp.Navigate method. It works fine on my PC.
Please provide the code of the OnClick event handler. I will test it.
Posted 10 Feb, 2010 09:49:22 Top
christianbpedersen




Posts: 34
Joined: 2009-07-19
This is the code of the onClick-handler:


private void adxieCommandItem1_OnClick(object sender, object e)
{
string sURL;
System.Object one = null;
System.Object two = null;
System.Object three = null;
System.Object four = null;

MessageBox.Show("Test");
sURL = "http://www.google.dk";
IEApp.Navigate(sURL, ref one, ref two, ref three, ref four);
}
Posted 10 Feb, 2010 16:45:14 Top
christianbpedersen




Posts: 34
Joined: 2009-07-19
I'm using IE8 on Windows 7 Ultimate
Posted 10 Feb, 2010 16:46:40 Top
christianbpedersen




Posts: 34
Joined: 2009-07-19
Are you having any luck reproducing this?
Posted 11 Feb, 2010 06:14:00 Top
christianbpedersen




Posts: 34
Joined: 2009-07-19
I have upgraded to Add-In Express 2010 for IE (Premium) - but it still fails.
Posted 11 Feb, 2010 09:28:36 Top
christianbpedersen




Posts: 34
Joined: 2009-07-19
This is the error message in its full length:

Detailed technical information follows:
---
(Inner Exception)
Date and Time: 2/11/2010 4:24:08 PM
Machine Name: WINDOWS7
IP Address: fe80::489e:3474:d550:56fa%11
Current User: windows7\admin

Application Domain: C:\Users\admin\Documents\Visual Studio 2005\Projects\Toolbar\Toolbar\bin\Debug\
Assembly Codebase: file:///C:/Windows/assembly/GAC_MSIL/AddinExpress.IE/6.0.365.0__4416dd98f0861965/AddinExpress.IE.dll
Assembly Full Name: AddinExpress.IE, Version=6.0.365.0, Culture=neutral, PublicKeyToken=4416dd98f0861965
Assembly Version: 6.0.365.0
Assembly Build Date: 2/11/2010 4:21:09 PM

Exception Source: Interop.SHDocVw
Exception Type: System.Runtime.InteropServices.COMException
Exception Message: The requested resource is in use. (Exception from HRESULT: 0x800700AA)
Exception Target Site: Navigate

---- Stack Trace ----
Interop.SHDocVw.IWebBrowser2.Navigate(URL As String, Flags As Object&, TargetFrameName As Object&, PostData As Object&, Headers As Object&)
AddinExpress.IE.dll: N 00000 (0x0) JIT
Toolbar.IEModule.adxieCommandItem1_OnClick(sender As Object, e As Object)
IEModule.cs: line 0138, col 13, IL 0128 (0x80)
AddinExpress.IE.ADXIECommandItem.DoClick(htmlDocument As Object)
AddinExpress.IE.dll: N 0023 (0x17) IL



(Outer Exception)
Date and Time: 2/11/2010 4:24:08 PM
Machine Name: WINDOWS7
IP Address: fe80::489e:3474:d550:56fa%11
Current User: windows7\admin

Application Domain: C:\Users\admin\Documents\Visual Studio 2005\Projects\Toolbar\Toolbar\bin\Debug\
Assembly Codebase: file:///C:/Windows/assembly/GAC_MSIL/AddinExpress.IE/6.0.365.0__4416dd98f0861965/AddinExpress.IE.dll
Assembly Full Name: AddinExpress.IE, Version=6.0.365.0, Culture=neutral, PublicKeyToken=4416dd98f0861965
Assembly Version: 6.0.365.0
Assembly Build Date: 2/11/2010 4:21:09 PM

Exception Source:
Exception Type: AddinExpress.IE.ADXIEExternalException
Exception Message: An error has occured in the code of the extension.
Exception Target Site: Object reference not set to an instance of an object.

---- Stack Trace ----
Posted 11 Feb, 2010 09:29:49 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Christian.

Please try to open a url in the OnSendMessage event handler:

private void adxieCommandItem1_OnClick(object sender, object htmlDoc)
{
this.SendMessage(0x400 + 1000, IntPtr.Zero, IntPtr.Zero);
}

private void IEModule_OnSendMessage(AddinExpress.IE.ADXIESendMessageEventArgs e)
{
if (e.Message == 0x400 + 1000)
{
object dummy = Type.Missing;

try
{
IEApp.Navigate("//www.add-in-express.com", ref dummy, ref dummy, ref dummy, ref dummy);
}
catch (Exception err)
{
MessageBox.Show(err.Message);
}
}
}
Posted 11 Feb, 2010 10:47:55 Top
christianbpedersen




Posts: 34
Joined: 2009-07-19
Hi Sergey,

That worked! Now I have another question (actually two):

1. Why does it work? Why is that different from just navigating from the OnClick event?

2. It looks like I'll have to select the values around "0x400 + 1000" with care. What do I need to be aware of here? Is there a valid space in e.Message I must stay within?

Best regards,
Christian
Posted 11 Feb, 2010 17:56:24 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Christian.

1. When you run the code from the OnClick event, IE executes a jscript which in its turn runs your code.
I am not sure but probably the SendMessage method allows you to postpone the request until IE is available.
2. 0x400 is the WM_USER constant reserved in Win32 API for custom messages.
You should define your messages as WM_USER + <an integer value>.
Posted 16 Feb, 2010 14:26:37 Top