簡體   English   中英

CLR名稱空間不存在

[英]CLR namespace does not exist

我有一個帶有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#項目作為參考 在此處輸入圖片說明

首先,請確保使用/ clr開關構建C ++項目。 奇怪的是,您至少沒有引用系統程序集。

其次,您提供的屏幕快照似乎表明您的C ++ / CLI項目正在使用.NET Framework v4.0。 假設您的C#項目正在使用.NET Framework v4.5,請嘗試更新您的C ++ / CLI項目以使其匹配。 您可以按如下方式手動編輯項目文件(.vcxproj):

<PropertyGroup Label="Globals">
    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>

我通過將Visual Studio 2013版本更改為v4.0來重現您的問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM