[英]Registration-free COM and DLL location
My C++ app was required to communicate with a web application. 我的C ++应用程序需要与Web应用程序通信。 Since writing in C++ was hard I wrote the web application client in C# (DLL), COM enabled it, and called it from C++ app and it worked.
由于用C ++编写很难,所以我用C#(DLL)编写了Web应用程序客户端,COM启用了它,并从C ++应用程序中调用了它,然后它起作用了。
But the C++ app can be installed on a server PC, its folder shared over a network, mapped to a drive on a client PC, and run from there. 但是C ++应用程序可以安装在服务器PC上,其文件夹通过网络共享,映射到客户端PC上的驱动器,然后从那里运行。 When I tried running so, it doesn't run because it is expecting the C# DLL to be registered on the client PC.
当我尝试运行时,它无法运行,因为它期望在客户端PC上注册C#DLL。 I would like to avoid it.
我想避免它。 I would like to keep them both on the server.
我想将它们都保留在服务器上。 Is it possible to do it using registration-free COM?
是否可以使用免注册COM来做到这一点? If yes, can the C# DLL (and its dependent DLLs) be placed in a folder different to the C++ EXE folder?
如果是,是否可以将C#DLL(及其相关DLL)放置在与C ++ EXE文件夹不同的文件夹中?
I see this is an outdated post. 我看到这是过时的帖子。 Hope you had found out a solution or a workaround.
希望您找到了解决方案或解决方法。 Anyhow, I shall answer as it may help someone with the same problem.
无论如何,我会回答,因为它可能会帮助遇到相同问题的人。
Is it possible to do it using registration-free COM?
是否可以使用免注册COM来做到这一点?
Yes, it is. 是的。 Follow this MSDN article .
遵循此MSDN文章 。 You will have to create a manifest for the c# com dll and embed the manifest into it.
您将必须为c#com dll创建一个清单,并将清单嵌入其中。 Which would be with the help of a RT_MANIFEST resource.
这将在RT_MANIFEST资源的帮助下进行。 That article is a little outdated, so you may face problem with .net framework version.
该文章有些过时,因此您可能会遇到.net Framework版本的问题。 If you did, you will need to specify the .net framework version in your machine.
如果这样做,则需要在计算机中指定.net框架版本。 You can simply replace the clrclass line with this :
您可以简单地用以下命令替换clrclass行:
<clrClass
clsid="{16AD5303-E154-44B4-A72B-C129859714AD}"
progid="SideBySide.SideBySide"
threadingModel="Both"
name="SideBySide.SideBySideClass"
runtimeVersion="v4.0.30319" >
can the C# DLL (and its dependent DLLs) be placed in a folder different to the C++ EXE folder?
可以将C#DLL(及其从属DLL)放置在与C ++ EXE文件夹不同的文件夹中吗?
Yes, it can be. 是的,可以。 But I wouldn't recommend it.
但是我不推荐它。 According to this resource, the assembly loader searches for assembly manifests in the following order :
根据此资源,程序集加载器按以下顺序搜索程序集清单:
Side-by-side searches the WinSxS folder.
\\<appdir>\<assemblyname>.DLL
\\<appdir>\<assemblyname>.manifest
\\<appdir>\<assemblyname>\<assemblyname>.DLL
\\<appdir>\<assemblyname>\<assemblyname>.manifest
The above locations are respective to the application (appdir). 以上位置分别与应用程序(appdir)有关。 If you want your dll to be elsewhere, then you can use the
file
element of the assembly manifest (the name
attribute can include a path), see here for more details and other elements. 如果您希望dll位于其他位置,则可以使用程序集清单的
file
元素( name
属性可以包含路径),有关更多详细信息和其他元素,请参见此处 。
Hope this helps someone. 希望这对某人有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.