CLR命名空间不存在

时间:2015-09-28 15:01:19

标签: c# c++-cli

我有一个带有2个功能的C#项目

namespace LibiqCommonStructures 
{
  public class BlackLevelData : List<BlackLevelLookupTable>
  {
      public BlackLevelData()
      {
      }

       public BlackLevelData(BlackLevelData original)
          : base(original.DeepCopy())
      {
      }

       public void AddLookupTable(double gain, double exposure, double[] levels)
      {
          var table = new BlackLevelLookupTable
          {
              AnalogGain = gain,
              ExposureTime = exposure,
             ChannelLevels = levels
          };

          Add(table);
      }
  }
}

SaturationLevelData

相同

我创建了一个c ++ \ CLI项目,我想将这两个类作为参数

添加到函数中
#pragma once
#include "Preprocessor.h"


using namespace LibiqCommonStructures;

namespace ToolBox {

    public ref class PreprocessorWrapper
    {
    public:        
        PreprocessorWrapper();        
        void Function1(BlackLevelData^ blackLevelData, SaturationLevelData^ saturationLevelData);
    private:
        Preprocessor* _preprocessor;
    };
}

 #include "PreprocessorWrapper.h"


void ToolBox::PreprocessorWrapper::Function1(BlackLevelData^ blackLevelData, SaturationLevelData^ saturationLevelData)
{    
    _preprocessor->Function1();
}

ToolBox::PreprocessorWrapper::PreprocessorWrapper()
{
    _preprocessor = new Preprocessor();
}

这是我得到的错误

Error   2   error C2871: 'LibiqCommonStructures' : a namespace with this name does not exist    g:\iqtool2\src\libiqtool\preprocessor_interop\PreprocessorWrapper.h 5   1   Preprocessor_interop
Error   8   error C2448: 'ToolBox::PreprocessorWrapper::Function1' : function-style initializer appears to be a function definition G:\IQTool2\src\libiqtool\Preprocessor_interop\PreprocessorWrapper.cpp   5   1   Preprocessor_interop
Error   6   error C2065: 'SaturationLevelData' : undeclared identifier  G:\IQTool2\src\libiqtool\Preprocessor_interop\PreprocessorWrapper.cpp   4   1   Preprocessor_interop
Error   7   error C2065: 'saturationLevelData' : undeclared identifier  G:\IQTool2\src\libiqtool\Preprocessor_interop\PreprocessorWrapper.cpp   4   1   Preprocessor_interop
Error   4   error C2065: 'BlackLevelData' : undeclared identifier   G:\IQTool2\src\libiqtool\Preprocessor_interop\PreprocessorWrapper.cpp   4   1   Preprocessor_interop
Error   5   error C2065: 'blackLevelData' : undeclared identifier   G:\IQTool2\src\libiqtool\Preprocessor_interop\PreprocessorWrapper.cpp   4   1   Preprocessor_interop
Error   3   error C2061: syntax error : identifier 'BlackLevelData' g:\iqtool2\src\libiqtool\preprocessor_interop\PreprocessorWrapper.h 13  1   Preprocessor_interop

你能看到我在这里做错了吗?

是的,我已添加C#项目作为参考 enter image description here

1 个答案:

答案 0 :(得分:3)

首先,确保使用/ clr开关构建C ++项目。奇怪的是,你至少没有引用系统组件。

其次,您提供的屏幕截图似乎表明您的C ++ / CLI项目正在使用.NET Framework v4.0。假设您的C#项目使用的是.NET Framework v4.5,请尝试更新您的C ++ / CLI项目以匹配。您可以按如下方式手动编辑项目文件(.vcxproj):

return done(null , false);

我通过使用Visual Studio 2013将版本更改为v4.0来重现您的问题。