Packaging .NET ActiveX

Packaging ActiveX controls written in unmanaged code is described pretty well. On the other hand packaging controls written in .NET is somewhat less documented. And you can get weird errors like “The style of the INF is different than what was requested.”

Creating .cab file is no magic. Just do:
cabarc N test.inf other.files
You can also use one of Visual Studio deployment projects. Ok, but what do you write inside the .inf file? While in case of unmanaged code you would write:




managed code needs somewhat convoluted approach:


[Setup Hooks]

run=msiexec.exe /i "%EXTRACT_DIR%\test.msi" /qn

Of course all of your code must be packaged into this test.msi file and placed inside .cab file. To create the .msi file you may use Visual Studio deployment project (again) or use other software such as WiX.

Debugging installation problems is not the most intuitive either. When installation fails you don’t directly get any error message. You have to go to Temporary Internet Files (Tools -> Internet Options -> Browsing history -> Settings -> View files…) and search for filenames starting with “?CodeDownloadErrorLog”. Then you have to drag the file to other folder and you can view it.

Sometimes the error messages found in this file are fairly descriptive, for example:
This installation package could not be opened. Verify that the package exists and that you can access it, or contact the application vendor to verify that this is a valid Windows Installer package.
(in this case the test.msi was not included in .cab file) and sometimes they are slightly more cryptic, for example:
Code Download Error: (hr = 800f0100) The style of the INF is different than what was requested.
(or in Polish: Code Download Error: (hr = 800f0100) Styl pliku INF jest inny niż żądano.)
This particular one results from saving the .inf file as UTF-8 encoding and not ANSI encoding and IMHO is particularly nasty as using notepad.exe it is hard to differentiate between ANSI and UTF encoded file. You can have a look at this problem using attached files (as the .cab files are unsigned you have to lower your security settings).

Another interesting thing is .NET ActiveX version handling. By default IE takes version of .NET Framework as component version (that is somethings like 2.0.50727.4016). If you want to set your own version (needed for proper component upgrade process) have a look at HKCR/CLSID/{GUID}/InstalledVersion/(Default) value and set it to something like “1,2,3,4″ (the InstalledVersion will have to be created separately in the msi file). Also have a look at this post.

Leave a Reply