The site is currently in read-only mode for maintenance. Posting of new items will be available again shortly.
There are a lot of extensions for the wonderful Band Objects
that Pavel Zolnikov has provided. I have been seeing a lot of queries regarding the implementations and deployment of the toolbars implementing the band objects.Here I will try to describe some common problems that many of us have experienced while working with the band object.
Problem #1 : Creating Strong Names For ActiveX Assemblies
The first problem that I will address here is with regards to the strong names of assemblies.
The strong naming of the BandObjectLib and the Implementing assembly very well in the above mentioned article itself.
The challenge is when the assemblies are copied into the GAC an error that occurs could be
Error 2 Assembly generation failed -- Referenced assembly 'Interop.SHDocVw' does not have a strong name .
This can happen due to the fact that the IE Engine component dosent have a strong name.
This can be resolved by adding the strong name to the SHDocVw through the following statement from the .NET command prompt.
sn -k shdocvw.snk
The first statement will generate a key used for signing the dll and the second statement will create the wrapper assemblies with strong names.
The second statement will result in the wrappers for the IE AxSHDocVw.dll and SHDocVw.dll which could be reffered in place of the earlier files
Problem #2 : IE Custom ToolBar Installer
Creating an installer for the band object is what I will deal with next.
I have created a sample project "ToolBar" for implementing the band objects and a setup project "ToolbarInstaller" for installing the ToolBar.
I will explain the different steps involved in this.
1. The first thing that we will do is Add an installer class to the ToolBar project. Right Click the ToolBar project -> Add New Item -> Installer Class
2. The installer class has some events associated with it . Form the designer view go to Properties -> Events ->
and double click on the After Install and the After Uninstall events.
We can use these events to run Regasm utility and Register/Unregister our dlls. The following code could be used to Register the dlls.
private void InstallToolBar_AfterInstall(object sender, System.Configuration.Install.InstallEventArgs e)
BandObjectPath = Assembly.GetExecutingAssembly().Location.Remove (
(Assembly.GetExecutingAssembly().GetName().Name.Length/ + 5));
BandObjectPath += "//BandObjectLib.dll/"; BandObjectPath = BandObjectPath.Replace(" ","");
ExecAssmPath = Assembly.GetExecutingAssembly().Location.Replace(" ","");
Process.Start (AppPath + "regasm.exe ",BandObjectPath);
Process.Start (AppPath + "regasm.exe ", ExecAssmPath);
EventLog.WriteEntry("Install Exception",ex.Message );
Similar code can be used for After UnInstall Function.
3. Now it is time to start the real installation works. First add a new setup project to the solution.Right click on the added setup project go to View -> FileSystem.
Right Click on the opened designer AddSpecialFolder -> Global Assembly Cache Folder
Right click on the GAC folder and Add -> Assembly and add the ToolBar as well as the Band
Object Assembly.This will add these assemblies into GAC during installations.
4. In order that the installer class Events to get triggered,We will have to
link the ToolBar dll to the Installer . For that we will right click on the installer project View -> CustomActions
Again Right Click on the Installation folder on the designer that opens up and click Add Custom Actions and select the application folder ,
browse for the ToolBar.dll and click OK.
This step is to be repeated for the UnInstall folder also.
Problem #3: Packaging .NET FrameWork With Your Application
Till this point we were dealing with installing the applicatio where there is .NET framework installed .What if it is not there .
For that the solution is straight forward.
- Download the BootStrapper.exe and install this .
- Right Click on the installer Project Go to Properties -> Boot Strapper and select Windows installer BootStrapper.
When your application is getting installed,it will automatically check for the .NET framework and install the same if it is not installed.
Problem #4: Adding ActiveXControls on the ToolBar
Loading an ActiveX controls on the toolbar is another problem that is very commonly faced. The Solution is very straight forward.
- Referring to Problem1 , use AxImp utility to add a strong name to the activex dlls
- Add these strong named Dlls to the GAC Using the gacutil
- Say Your Application is located at C:\MyToolBar
Go to the .NET Command prompt (Start -> ProgramFiles ->VisulaStudio.NET---- ->VisualStudio.NETTools -> Visual Studio .NET Command Prompt) and type
gacutil /if C:\MyToolBar\bin\debug\ActiveX.dll .
If you are using the above installer add the dlls into the GAC using the 3 rd step in Problem #2.
Using the installer that i have created , it is not possible to install the toolbar in C:\Program Files\...
This is Because I couldnt find a straightforward method to get the DOS Path from .NET. There is one method GetShortPathName() in Win32 .
Interested people can read more.
The above mentioned installer will work only on .NET 2003 since the app path is taken
private string AppPath = @"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\";
The folder will be something different for other versions.
The Solutions that I have tried to provide maynot be the best and also not the singular ones. All Suggestions /Comments/Criticisms are whole heartedly welcomed. Please do keep posting about the various problems that you people face while creating the IE toolBars So that I can Keep appending to what is done.