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

时光怂恿深爱的人放手 提交于 2019-12-11 00:17:03

问题


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:


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



来源:https://stackoverflow.com/questions/4947117/reg-free-com-location-of-com-dll-relative-to-client-exe

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!