Home All Groups Group Topic Archive Search About

Instantiate Shell.Explorer.2 at runtime for a web page

Author
12 Jan 2006 6:57 PM
jmi0@att.net
I want to create a custom user control to be used in a web page (by
object tag) as an assembly. The user control needs to have a web
browser control in it. Having tried with the managed
System.Windows.Forms.WebBrowser or AxSHDocVw.AxWebBrowser, none of them

worked  from IE invocation unfortunately. While
System.Windows.Forms.WebBrowser showed the page in Visual Studio 5000
Designer, AxSHDocVw.AxWebBrowser caught an exception at Navigate
function call.

Anyway, now I'm trying to use Shell.Explorer.2 in my custom user
control at runtime. The way I instantiate it is such:
            Type loT = Type.GetTypeFromProgID("Shell.Explorer.2");
            this.IE = Activator.CreateInstance(loT);
Then, this.IE can access all the properties of the ActiveX control,
like MenuBar, ToolBar etc.
However, it failed at, again, calling Navigate method. Debugger won't
step over the call.

If I replace Shell.Explorer.2 with InternetExplorer.Application, it
worked fine. Except that's not what I wanted because it launches IE in
a separate window.

Interestingly enough, if I embed Shell.Explorer.2 with its classid
directly into my web html page. It showed well, except the html object
id lost the reference to the control after exiting the onload function
in my javascript.

I must have missed something fundamantal in this attempt. Really hope
someone can direct me a little.

Thanks,
Jason

Author
12 Jan 2006 11:57 PM
jmi0@att.net
Well, I think all these might be due to the argument TargetFrameName
passed to the method Navigate() of the Web Browser control. When a new
window (either a name string in javascript or boolean true for new
window in a C# assembly) is specified for the argument, the object
instance lives. Otherwise, it dies.

I now need to figure out the right value for it. I used the html frame
name for it in a direct embedding. The control won't display. I don't
know what to pass to it in my custom C# user control which contained
the browser control.

Jason
Author
13 Jan 2006 5:15 AM
Rashad Rivera
I wanted to ask you a question about your attempts to use
"System.Windows.Forms.WebBrowser" and "AxSHDocVw.AxWebBrowser".  When you
loaded your solution in IE, did you sign or "strong name" your control and
add it's public key to the computer's trusted applications list in .NET
2.0/1.1?  If not, then you may experience issues where it would not work,
but really IE is not loading the control because of it's security settings
which abide by the .NET application settings.  See below:

http://www.dotnet247.com/247reference/articles/2/12986.aspx

There is nothing in this page but the link to the article which is:
http://www.dotnet247.com/247reference/a.aspx?u=http://www.kbalertz.com/kb_839300.aspx

Keep in mind that I used this article before to do this same thing, but the
author was missing something that I can not recollect at this time.  Let me
know if this helps. If not, then let me know what the symptoms are.

- Rashad Rivera spam@omegusprime.com
  www.omegusprime.com




<j***@att.net> wrote in message
Show quoteHide quote
news:1137092257.809845.75060@g14g2000cwa.googlegroups.com...
>I want to create a custom user control to be used in a web page (by
> object tag) as an assembly. The user control needs to have a web
> browser control in it. Having tried with the managed
> System.Windows.Forms.WebBrowser or AxSHDocVw.AxWebBrowser, none of them
>
> worked  from IE invocation unfortunately. While
> System.Windows.Forms.WebBrowser showed the page in Visual Studio 5000
> Designer, AxSHDocVw.AxWebBrowser caught an exception at Navigate
> function call.
>
> Anyway, now I'm trying to use Shell.Explorer.2 in my custom user
> control at runtime. The way I instantiate it is such:
>            Type loT = Type.GetTypeFromProgID("Shell.Explorer.2");
>            this.IE = Activator.CreateInstance(loT);
> Then, this.IE can access all the properties of the ActiveX control,
> like MenuBar, ToolBar etc.
> However, it failed at, again, calling Navigate method. Debugger won't
> step over the call.
>
> If I replace Shell.Explorer.2 with InternetExplorer.Application, it
> worked fine. Except that's not what I wanted because it launches IE in
> a separate window.
>
> Interestingly enough, if I embed Shell.Explorer.2 with its classid
> directly into my web html page. It showed well, except the html object
> id lost the reference to the control after exiting the onload function
> in my javascript.
>
> I must have missed something fundamantal in this attempt. Really hope
> someone can direct me a little.
>
> Thanks,
> Jason
>