2
votes

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
Just to add to this - I have tried using activation context api as well. As explained above, I want my client to load a COM dll that is not in the same directory as the client.exe. I attempted to do this by setting the assembly directory on the activation context to point at a directory containing a manifest file and the COM dll. The result is that the manifest file is found correctly but when it tries to load the accompanying dll it looks in a path relative to the client.exe rather than the directory where it found the manifest. Am I missing something?HammerIp
Relative paths do work, i.e. you can put the dlls in .\External folder, relative to the exe. Just use <file name="External\My.dll"> in manifest.wqw
I guess that's relative, but it only works in the same or lower directory level.Jeff

1 Answers

4
votes

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