Using .NET windows forms controls in an _embedded_ browser control

  • Thread starter Thread starter Manny Vellon
  • Start date Start date
M

Manny Vellon

I'm interested in using .net windows forms controls (datagrid, etc.) in my
app. My app, however, uses an embedded web browser control for its UI (for
easier content authoring). Pages are loaded locally (using file:// urls).

I've read examples of how to do this with IE and http protocol, but can it
be done locally with file protocol? I've tried:

<object classid="file:foo.dll#BarNS.Class" ...

As well as "foo.dll#Bar.NS.Class" and many other more options but all I get
is the old red "x".

Is it impossible to do this?
 
Hi Manny,

Not tested this, but it appears that your file URL is malformed. Here's how
I'd write it:

<object classid="file:///./foo.dll#BarNS.Class" ...
 
Thanks, Dmytro, I've tried a bunch of alternatives, though, and I believe
(based on my readings) that IE only supports http protocol here. This is
unfortunate as it means that using IE without a web server to serve up pages
with winforms controls is not possible. I'd prefer to not have to run
Cassini just to deal with this problem.

I have discovered a somewhat painful alternative, however: I can use a C++
..net shim to load my C# Winforms control. The shim is an activex control
implemented in ATL7 that loads my control indirectly. I'm sure I'll have to
struggle with some container issues, but it's a promising avenue.

Dmytro Lapshyn said:
Hi Manny,

Not tested this, but it appears that your file URL is malformed. Here's
how I'd write it:

<object classid="file:///./foo.dll#BarNS.Class" ...

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]


Manny Vellon said:
I'm interested in using .net windows forms controls (datagrid, etc.) in
my app. My app, however, uses an embedded web browser control for its UI
(for easier content authoring). Pages are loaded locally (using file://
urls).

I've read examples of how to do this with IE and http protocol, but can
it be done locally with file protocol? I've tried:

<object classid="file:foo.dll#BarNS.Class" ...

As well as "foo.dll#Bar.NS.Class" and many other more options but all I
get is the old red "x".

Is it impossible to do this?
 
You could also register the object for interop and load it with the
object tag and GUID.
Example here.

http://support.microsoft.com/default.aspx?scid=kb;en-us;Q305624

I am doing this but have a problem. I need to be able to load the
app.config file for this control and I don't know if its possible using
the anonymously generated appDomain that gets created.

That shim idea may be an alternative that works for me.
 
Interesting...I remember that Microsoft told some time ago that while COM
interop was fully supported by the framework, an ability to expose WinForms
user controls as ActiveX controls had been removed from the 1.0 release due
to certain problems it had.

Probably the story is different with IE which supports so-called lightweight
ActiveX controls, probably the framework supports those.

As for the app.config, it seems to be tough luck - I am not sure what to
advise.
 
Back
Top