views:

5790

answers:

7

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?

+4  A: 

Make My Manifest (MMM) is a nice tool for doing this. It's also possible to write a script to process all your DLL/OCX files using mt.exe to generate a manifest for each one and then merge them all together. MMM is usually better/easier, because it also handles lots of special/weird cases.

I'm a bit nervous about this MMM thing; it's just a blog, freeware but no source code available, only a link to a "self-extracting exe" and I see comments about the utility causing XP to crash. mmm...
Wim Coenen
Those "crashes" were the MMM utility itself dying. This was fixed in version 0.6.5 but you'll want 0.6.6 anyway, since while still a beta it no longer expires.You can always use MT.EXE instead though as already suggested.
Bob
mt.exe is not generating progid's when I use it on native com servers like dbgrid32.ocx
Wim Coenen
Use of reg free COM with .NET authored components can apparently cause XP to crash - see this http://stackoverflow.com/questions/617253/is-anyone-successfully-using-registration-free-com-with-net-components
MarkJ
+4  A: 

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).

Wim Coenen
I think you missed one option: http://www.mazecomputer.com/ but I know nothing about it the web site doesn't describe.
Bob
MMM will also redirect non-COM (standard) DLLs. I'm not sure the other tools do this.
Bob
A: 

mt.exe worked great for my large c# project in VS2005. Now I can use my ocx without registering it. Thanks!

+2  A: 

You can use Unattended Make My Manifest spin off to generate manifests directly in automated builds. It uses a script file to add depended COM components. This is an excerpt from the sample ini with the available commands:

# Unattended MMM script
#
# Command names are case-insensitive. Reference of supported commands:
#
# Command: Identity
#
#   Appends assemblyIdentity and description tags.
#
#   Parameters       <exe_file> [name] [description]
#      exe_file      file name can be quoted if containing spaces. The containing folder 
#                    of the executable sets base path for relative file names
#      name          (optional) assembly name. Defaults to MyAssembly
#      description   (optional) description of assembly
#
# Command: Dependency
#
#   Appends dependency tag for referencing dependent assemblies like Common Controls 6.0, 
#     VC run-time or MFC
#
#   Parameters       {<lib_name>|<assembly_file>} [version] [/update]
#     lib_name       one of { comctl, vc90crt, vc90mfc }
#     assembly_file  file name of .NET DLL exporting COM classes
#     version        (optional) required assembly version. Multiple version of vc90crt can
#                    be required by a single manifest
#     /update        (optional) updates assembly_file assembly manifest. Spawns mt.exe
#
# Command: File
#
#   Appends file tag and collects information about coclasses and interfaces exposed by 
#     the referenced COM component typelib.
#
#   Parameters       <file_name> [interfaces]
#     file_name      file containing typelib. Can be relative to base path
#     interfaces     (optional) pipe (|) separated interfaces with or w/o leading 
#                    underscore
#
# Command: Interface
#
#   Appends comInterfaceExternalProxyStub tag for inter-thread marshaling of interfaces
#
#   Parameters       <file_name> <interfaces>
#     file_name      file containing typelib. Can be relative to base path
#     interfaces     pipe (|) separated interfaces with or w/o leading underscore
#
# Command: TrustInfo
#
#   Appends trustInfo tag for UAC user-rights elevation on Vista and above
#
#   Parameters       [level] [uiaccess]
#     level          (optional) one of { 1, 2, 3 } corresponding to { asInvoker, 
#                    highestAvailable, requireAdministrator }. Default is 1
#     uiaccess       (optional) true/false or 0/1. Allows application to gain access to 
#                    the protected system UI. Default is 0
#
# Command: DpiAware
#
#   Appends dpiAware tag for custom DPI aware applications
#
#   Parameters       [on_off]
#     on_off         (optional) true/false or 0/1. Default is 0
#
# Command: SupportedOS
#
#   Appends supportedOS tag
#
#   Parameters       <os_type>
#     os_type        one of { vista, win7 }. Multiple OSes can be supported by a single 
#                    manifest
#
wqw
+1 Interesting, especially because the source code is available. I'm a bit confused by the name similarity, apparently "make my manifest" and "unattended make my manifest" are different tools by different authors.
Wim Coenen
A: 

here is a freeware GUI version of regsvr42: www.mediafire.com/?222e2xdn5yt worked well for me for native com libraries from Win98 to Win7

tzitech
A: 

the old file has bugs. here is the updated file for the Manifest Wizard (GUI version of regsvr42): Manifest Wizard

tzitech
Please link to the source or project page. A link from a freshly created stackoverflow user, to a naked exe on a random file hosting service is simply too suspicious.
Wim Coenen
A: 

your Manifest Wizard works great with native com libraries but not with .net. can you extend its functions? or maybe you can share the source code.

dion