Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate manifest files for registration-free COM

I have some applications (some native, some .NET) which use manifest files so that they can be deployed in complete isolation, without requiring any global COM registration. For example, the dependency on the dbgrid32.ocx com server is declared as follows in the myapp.exe.manifest file which sits in the same folder as myapp.exe:

<?xml version="1.0" encoding="utf-8" standalone="yes"?> <assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">   <assemblyIdentity type="win32" name="myapp.exe" version="1.2.3.4" />   <dependency>     <dependentAssembly>       <assemblyIdentity type="win32" name="dbgrid32.ocx" version="5.1.81.4" />     </dependentAssembly>   </dependency> </assembly> 

The dbgrid32.ocx is deployed to the same folder, along with it's own dbgrid32.ocx.manifest file:

<?xml version="1.0" encoding="utf-8" standalone="yes"?> <assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">   <assemblyIdentity type="win32" name="dbgrid32.ocx" version="5.1.81.4" />   <file name="dbgrid32.ocx">      <typelib         tlbid="{00028C01-0000-0000-0000-000000000046}"         version="1.0"         helpdir=""/>     <comClass progid="MSDBGrid.DBGrid"        clsid="{00028C00-0000-0000-0000-000000000046}"        description="DBGrid  Control" />   </file> </assembly> 

This all works fine but maintaining these manifest files manually is a bit of a pain. Is there a way to generate these files automatically? Ideally I would just like to declare the application's dependency on a list of COM servers (both native and .NET) and then let the rest be generated automatically. Is it possible?

like image 618
Wim Coenen Avatar asked Jan 21 '09 16:01

Wim Coenen


People also ask

How do you create a manifest file?

You can tell Visual Studio to generate a manifest file for a particular project in the project's Property Pages dialog. Under Configuration Properties, select Linker > Manifest File > Generate Manifest. By default, the project properties of new projects are set to generate a manifest file.

Is Interop free?

Requirements for registration-free COM interopSupport for registration-free COM interop varies slightly depending on the type of library assembly; specifically, whether the assembly is unmanaged (COM side-by-side) or managed (. NET-based).

Where can I find manifest file?

The file is located at WorkspaceName>/temp/<AppName>/build/luaandroid/dist. The manifest file provides essential information about your app to the Android operating system, and Google Play store. The Android manifest file helps to declare the permissions that an app must have to access data from other apps.

What is manifest DLL?

A manifest is some XML (typically embedded into . dll and .exe files) which can (among other things) specify the exact version of the Microsoft Visual C++ runtime (MSVCRT) that an application requires.


1 Answers

It looks like the perfect solution does not yet exist. To summarize some research:

Make My Manifest (link)

This tool scans a VB6 project to look for COM dependencies, but it also supports manual declaration of late-bound COM dependencies (i.e. those used via CreateObject).

Interestingly enough, this tool puts all information about the dependencies inside the application manifest. The application exe and its dependencies are described as a single assembly consisting of multiple files. I hadn't realized before that this was possible.

Looks like a very good tool but as of version 0.6.6 it has the following limitations:

  • only for VB6 applications, starts from VB6 project file. Shame, because a lot of what it does really has nothing to do with VB6.
  • wizard style application, not suitable to integrate in a build process. This is not a huge problem if your dependencies don't change a lot.
  • freeware without source, risky to rely on it because it could become abandonware at any moment.

I did not test whether it supports .NET com libraries.

regsvr42 (codeproject link)

This command line tool generates manifest files for native COM libraries. It invokes DllRegisterServer and then spies on the self-registration as it adds information into the registry. It can also generate a client manifest for applications.

This utility does not support .NET COM libraries, since these don't expose a DllRegisterServer routine.

The utility is written in C++. The source code is available.

mt.exe

Part of the windows SDK (can be downloaded from MSDN), which you already have if you have visual studio installed. It is documented here. You can generate manifest files for native COM libraries with it like this:

mt.exe -tlb:mycomlib.ocx -dll:mycomlib.ocx -out:mycomlib.ocx.manifest 

You can generate manifest files for .NET COM libraries with it like this:

mt.exe -managedassemblyname:netlib.dll -nodependency -out:netlib.dll.manifest 

However, there are some problems with this tool:

  • The first snippet will not generate progid attributes, breaking clients which use CreateObject with progids.
  • The second snippet will generate <runtime> and <mvid> elements which need to be stripped out before the manifests actually work.
  • Generation of client manifests for applications is not supported.

Maybe future SDK releases will improve this tool, I tested the one in the Windows SDK 6.0a (vista).

like image 132
Wim Coenen Avatar answered Nov 05 '22 10:11

Wim Coenen