Reg-free COM - location of COM dll relative to client exe

1.2k views Asked by At

I want to use reg-free com so that I don't have to register my legacy com component. However, I would like to be able to put the com dll in a location which is not in or below the directory of the client exe, e.g. ....\lib. I'm not able to do this in the server manifest file as it doesn't allow relative or absolute paths.

Does anyone know if there is a way round this?


UPDATE: I only found relative paths to work on XP. However, I can use absolute paths on Windows Server 2008 using the Activation Context API so that's cool. My problem now is that my COM component has a static dependency on a managed database driver but currently it's not finding it. From what I've read about manifest files I hoped I could simply add another element to the COM reg-free manifest pointing at this dll as it is in the same directory as the COM dll but I can't get it to work. So, in summary, I have an exe in one directory which uses Activation Context API to reference a COM manifest/dll in another directory (that is not a subdirectory of the exe directory) which it finds and loads correctly. But I also have a managed database driver dll in the same directory as the COM dll and I want to know how I can get this to load using manifest files - if it's possible.

1

There are 1 answers

1
Timje On

I've achieved this by running the exe with the parent directory as the current directory. i.e with this folder structure

  • parentdir/
  • parentdir/myapp/
  • parentdir/somedependency/

Then with "parentdir" as the current directory, you can run your exe as ".\myapp\myapp.exe" and myapp.exe.manifest can contain a reference to something in "somedependency" as

<file name=".\somedependency\somecomassembly.dll" />

This works on Windows Server