免注册COM-COM dll相对于客户端exe的位置 [英] Reg-free COM - location of COM dll relative to client exe

查看:83
本文介绍了免注册COM-COM dll相对于客户端exe的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用免注册com,这样就不必注册我的旧com组件。但是,我希望能够将com dll放置在客户端exe目录之内或之下的位置。 .... lib。我无法在服务器清单文件中执行此操作,因为该文件不允许相对或绝对路径。

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?

更新:
我只找到在XP上工作的相对路径。不过,我可以在Windows Server 2008上使用Activation Context API使用绝对路径,这很酷。现在的问题是我的COM组件对托管数据库驱动程序具有静态依赖性,但是目前找不到它。从我阅读的清单文件中,我希望我可以简单地向指向该dll的COM无限制清单添加另一个元素,因为它与COM dll位于同一目录中,但我无法使其正常工作。因此,总而言之,我在一个目录中有一个exe,该目录使用激活上下文API来引用另一个目录中的COM清单/ dll(不是exe目录的子目录),该目录可以正确找到并加载。但是我在与COM dll相同的目录中也有一个托管数据库驱动程序dll,并且我想知道如何使用清单文件来加载它(如果可能)。

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.

推荐答案

我已经通过以父目录作为当前目录运行exe来实现了这一目标。
即具有此文件夹结构

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 /

然后使用 parentdir作为当前目录,您可以运行exe为
.\myapp\myapp.exe
和myapp.exe.manifest可以包含对 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" />

此功能适用于Windows Server

This works on Windows Server

这篇关于免注册COM-COM dll相对于客户端exe的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆