Mozilla ActiveX Control is unuseable as a subclassed control in .Net 2.0



13 years ago
7 years ago


(Reporter: norman, Unassigned)



Windows XP

Firefox Tracking Flags

(Not tracked)



(1 attachment, 2 obsolete attachments)



13 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:; .NET CLR 1.0.3705; .NET CLR 1.1.4322; .NET CLR 2.0.50727) Gecko/20060508 Firefox/
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:; .NET CLR 1.0.3705; .NET CLR 1.1.4322; .NET CLR 2.0.50727) Gecko/20060508 Firefox/

I've subclassed the System.Windows.Forms.WebBrowser as such:

    class MozillaWebBrowser : WebBrowser
        public MozillaWebBrowser()
            Guid clsid = new Guid("1339b54c-3453-11d2-93b9-000000000000");
            typeof(WebBrowserBase).InvokeMember("clsid", BindingFlags.SetField | BindingFlags.Instance | BindingFlags.NonPublic, null, this, new object[] { clsid });

This enables me to add a Web Browser control to a form, and it uses the Mozilla rendering engine.  However certain functionality fails to work: 

    HtmlDocument doc = mozillaWebBrowser1.Document;

The (built-in .net) Document property retrieves the IHTMLDocument2 interface and calls GetLocation (get_location), which is NotImplemented, so the entire method fails.

Reproducible: Always

Steps to Reproduce:
1. Create MozillaWebBrowser Class as described above
2. Add MozillaWebBrowser control to a new System.Windows.Forms.Form as mozillaWebBrowser1
3. Access mozillaWebBrowser1.Document (in Form_Load or Button1_Click)

Actual Results:  
Application Crashes:
System.NotImplementedException: The method or operation is not implemented.
   at System.Windows.Forms.UnsafeNativeMethods.IHTMLDocument2.GetLocation()
   at System.Windows.Forms.WebBrowser.get_Document()

Expected Results:  
HtmlDocument object should be returned (HtmlDocument is a wrapper for IHtmlDocument2 - but the document's location is required to 'build' the wrapper)

I expect a few more bugs to come up once this one is fixed.  Currently I'm limiting code to getElementById (IHTMLDocument3), and setting styles (IHTMLElement.GetStyle, and IHTMLStyle.{Get/Set}CssText()).  Both of those are NotImplemented at the moment. :-(

Comment 1

13 years ago
Sorry, meant to add that pages load in the control perfectly, it's just the access to the dom objects that's impossible, because of the properties the .net wrappers try and access.

Comment 2

13 years ago
reporter: i don't suppose you could work on fixing this? i'm not sure how much time adamlock has to do this work.
Severity: normal → enhancement
Keywords: helpwanted

Comment 3

13 years ago
Here's my first pass at adding code to the activex control.  This gets makes the document object available to the .net framework.

If someone could comment on where I should be doing the nsIDOMWindowInternal - in control/IEHtmlDocument (like it is atm) or common/IEHtmlLocation (make a CreateFromSomething method that takes ref to document or window or something) that would be great.

(Next up IHTMLDocument3 support for getElementById)

Comment 4

13 years ago
Should I fold common/IHTMLLocationImpl.h into common/IEHtmlLocation.h?

I believe that plugin/XPCDocument.cpp uses it, so I'm scared to touch it.

Comment 5

13 years ago
Norman, I'm going to try and remember to send you a private mail very soon: I have concerns about trying to emulate the full MSHTML DOM interfaces, and I was thinking about dropping all of that emulation in favor of an IDispatch wrapper around XPCOM. This may not suit your .NET needs though.

Comment 6

13 years ago
Added IHTMLDocument3.getElementById
Attachment #225467 - Attachment is obsolete: true

Comment 7

13 years ago
This is the complete patch required to implement the methods I'm trying to use from .Net.  It is hardly feature complete, but it does add some critical functionality like getElementById and style.
Attachment #226088 - Attachment is obsolete: true


11 years ago
Assignee: adamlock → nobody
QA Contact: dunn5557 → activex
Ever confirmed: true
The ActiveX embedding API was removed in bug 662023 and friends, making this INVALID.

[Filter bugspam on activexinvalid]
Last Resolved: 8 years ago
Resolution: --- → INVALID
Component: Embedding: ActiveX Wrapper → Embedding: ActiveX Wrapper
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.