Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/340.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/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
C# 链接本机/C++;DLL到托管C++/VisualStudio2010中的CLI包装器 在我的VisualStudio解决方案中,我有一个包含本地C++代码的DLL,一个C++/CLI DLL,我试图为我的非托管类型实现一个包装器,最后是我的C语言应用程序。_C#_Visual Studio 2010_Dll_Linker_C++ Cli - Fatal编程技术网

C# 链接本机/C++;DLL到托管C++/VisualStudio2010中的CLI包装器 在我的VisualStudio解决方案中,我有一个包含本地C++代码的DLL,一个C++/CLI DLL,我试图为我的非托管类型实现一个包装器,最后是我的C语言应用程序。

C# 链接本机/C++;DLL到托管C++/VisualStudio2010中的CLI包装器 在我的VisualStudio解决方案中,我有一个包含本地C++代码的DLL,一个C++/CLI DLL,我试图为我的非托管类型实现一个包装器,最后是我的C语言应用程序。,c#,visual-studio-2010,dll,linker,c++-cli,C#,Visual Studio 2010,Dll,Linker,C++ Cli,我当前无法在包装器dll中引用非托管类型 代码段: // In the unmanged file (in the unmanged dll project) using std::vector; namespace populationwin32 { class PopulationWin32 { public: PopulationWin32(); // ... }; } // In the managed file. (in the manged dll p

我当前无法在包装器dll中引用非托管类型

代码段:

// In the unmanged file (in the unmanged dll project)
using std::vector;
namespace populationwin32 
{
  class PopulationWin32
  {
  public:
    PopulationWin32();
  // ...
  };
}

// In the managed file. (in the manged dll project)
using namespace system;
using populationwin32::PopulationWin32;
namespace GSODFileParsing 
{
  public ref class PopulationWin32Wrapper
  {
  public:
    PopulationWin32Wrapper();
  private:
    PopulationWin32 *_populationWin32; // unmanaged object   
  }; // End class
} // End namespace
当我尝试编译托管dll(包含包装器)时,会出现以下错误:

Error   1   error C2653: 'populationwin32' : is not a class or namespace name
Error   2   error C2873: 'PopulationWin32' : symbol cannot be used in a using-declaration
Error   4   error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   
你知道这些错误是什么意思吗?我想他们是因为没有正确链接到未管理的dll,但我不确定如何做到这一点,我在网上找到的一切都说明了一些不同的情况。有谁知道如何正确、完整地将非托管库(dll项目)与托管VC++/CLI包装库(dll项目)链接

注意:这两个库都是单个VisualStudio解决方案中的项目

编辑:感谢我添加的Olaf Dietsche的评论

#include "PopulationWin32.h"
到包装器头文件,但现在出现以下错误:

错误1错误C1083:无法打开包含文件:“PopulationWin32.h”:没有此类文件或目录


是否缺少设置,或者是否需要在两个DLL项目中都包含头文件?顺便说一句,我通过properties->configuration properties->linker->input->Additional Dependencies将unmanged dll output.lib文件作为一个依赖项添加到托管dll中。

您的第一个错误
'populationwin32':不是类或命名空间名称
意味着编译器不知道这个命名空间

添加

#include "PopulationWin32.h"
使Visual Studio了解这一点


您还必须将路径添加到包含文件中,以便编译器可以找到它。例如,这里和这里都有描述。

您的第一个错误
'populationwin32':不是类或命名空间名称
意味着编译器不知道此命名空间

添加

#include "PopulationWin32.h"
使Visual Studio了解这一点


您还必须将路径添加到包含文件中,以便编译器可以找到它。例如,这里和这里都有描述。

您是否包含了
populationwin32::populationwin32
的头文件?您没有用分号关闭populationwin32的类声明。@OlafDietsche谢谢,请参阅我上面的编辑。@TimoGeusch实际上我在发布问题时没有使用分号。我编辑了这篇文章。感谢您的评论。这意味着编译器错过了
填充Win32.h
的路径。您必须将其添加到编译器的包含路径中。您是否包含了
populationwin32::populationwin32
的头文件?您没有用分号关闭populationwin32的类声明。@OlafDietsche谢谢,请参阅我上面的编辑。@TimoGeusch实际上我在发布问题时使用了分号,而不是。我编辑了这篇文章。感谢您的评论。这意味着编译器错过了
填充Win32.h
的路径。必须将其添加到编译器的include路径。