Go to content Go to navigation Go to search
Snippet: Design time support for a web control in C# · Mar 28, 08:42 AM

Part 1: Embedding a web control in C#

Design time support

Although it’s nice to be able to create controls by hand, in most cases developers want controls to be available at design-time. For Visual Studio users this capability is almost built-in. Visual Studio will even automatically wrap ActiveX controls for you (eliminating needing to call AxImp.exe by hand).

To take advantage of this right-click Windows Forms Toolbox and select “Add/Remove Items…”. In the “Customize ToolBox” dialog select the COM Components tab. Then scroll through the list and put a check next to “Microsoft Web Browser” and “MozillaBrowser Class” if you have the Mozilla ActiveX Control installed. Then press OK and you should see two entries added to the toolbox.

You can now drag these onto your Windows Forms application and go to town with them. If you look in the output directory you’ll find the ActiveX wrapper assemblies (runtime callable wrapper or RCW assemblies).

Now, even though this seems simple there are some problems with this technique. Probably the biggest problem is a problem with all ActiveX and other COM controls: keeping track of them. It’s very easy to use third-party controls, even by accident. Since they are early-bound, if they are not present on the user’s machine the program using them will not even load. So keeping track of what controls are installed on your machine and testing on a cleanly-installed system are essential. VMWare Workstation is a life-saver for this.

Second, discovery is a pain. Knowing that Microsoft or a third-party has provided the functionality that you want is hard enough but can usually be found by searching documentation or the web. However, even when it’s installed on your machine they can be a chore to find. The “Customize Toolbox” is terrible. It’s not sizeable (all browsers should be sizeable) and it desperately needs at least a search filter to pare down the list of hundreds of items. Since it lacks these basic features and I usually know the name of the DLL and where it’s installed I usually sort on the “Path” column and use that to find the control I’m looking for.

  1. Hello,

    I want to use the Mozilla embed, but when I try to compile the code you supplied for it, I get a Class Not Registered error: REGDB_E_CLASSNOTREG.

    I tried running regevr32 on the mozilla DLL’s but that gives me an error saying that there’s no entry point.

    Do you have any ideas how to get beyond this?


    — AG    Mar 28, 01:46 PM    #
  Textile Help

Snippet: Embedding a web control in C#