Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio 2012 无法将COM DLL添加为VS 2012项目的引用_Visual Studio 2012_Dll - Fatal编程技术网

Visual studio 2012 无法将COM DLL添加为VS 2012项目的引用

Visual studio 2012 无法将COM DLL添加为VS 2012项目的引用,visual-studio-2012,dll,Visual Studio 2012,Dll,我试图添加一个使用Visual Studio.NET 2003 ATL COM项目构建的COM DLL,当我点击浏览并选择DLL时,我得到以下错误 A reference to 'MyCOM.dll' could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component. 但是,当我使用RegSvr32.exe注册它,并使用引用窗口中的

我试图添加一个使用Visual Studio.NET 2003 ATL COM项目构建的COM DLL,当我点击浏览并选择DLL时,我得到以下错误

A reference to 'MyCOM.dll' could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component.
但是,当我使用
RegSvr32.exe注册它,并使用引用窗口中的COM窗格浏览它并添加它时,它工作得很好


我怎样才能只添加dll而不必注册它呢?

这不是那么容易做到的,因为COM总是使用注册表来查找dll。在代码中,您仅使用库的GUID引用库,而不使用库在文件系统中的位置。幸运的是,这并不完全正确(现在)。有两种可能绕过这一点:

  • 使用Reg Free COM,这需要向可执行文件添加清单。它包含注册信息而不是注册表。谷歌免费注册COM和清单
  • 通常,也可以通过普通方式(使用lib文件)链接dll,并使用简单的新调用创建“COM”对象。不过,这要求您拥有完整的头文件。而且它不再真正使用COM了