Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/132.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++/本机c++;在LabView中使用_C++_C++ Cli_Wrapper_Shared Ptr_Labview - Fatal编程技术网

C++ c++/本机c++;在LabView中使用

C++ c++/本机c++;在LabView中使用,c++,c++-cli,wrapper,shared-ptr,labview,C++,C++ Cli,Wrapper,Shared Ptr,Labview,我正在尝试为IO Industries Core2 DVR编写一个c++/cli包装器,然后LabView将使用它。该公司提供了一个SDK,其中包含所有标题(用c++编写)和boost库。我已经成功地构建了一个包装器来构建,并且LabView能够通过.net托盘查看函数 // ManagedProject.h #pragma once #include "core_api_helper.h" #include "core_api.h" using namespace System; usi

我正在尝试为IO Industries Core2 DVR编写一个c++/cli包装器,然后LabView将使用它。该公司提供了一个SDK,其中包含所有标题(用c++编写)和boost库。我已经成功地构建了一个包装器来构建,并且LabView能够通过.net托盘查看函数

// ManagedProject.h

#pragma once
#include "core_api_helper.h"
#include "core_api.h"


using namespace System;
using namespace CoreApi;

namespace ManagedProject {

//Setup class
public ref class Setup
{
private:

public:
    unsigned int initializeTest();

};
}
//这是DLL包装器

#include "stdafx.h"

#include "ManagedProject.h"
#include "core_api_helper.h"
#include "core_api.h"
#include "resource.h"

using namespace CoreApi;
using namespace Common;
using namespace ManagedProject;

//Global handles

//A handle to the Core Api
InstanceHandle g_hApi;

//A handle to the Core Api Device Collection
DeviceCollectionHandle g_hCoreDeviceCollection;


unsigned int Setup::initializeTest()
{

try
{
    //Initialize the Core API (must be called before any other Core API functions)
    //Returns a handle to the Core Api
    g_hApi = Instance::initialize();

    // get a collection of Core devices
    g_hCoreDeviceCollection = g_hApi->deviceCollection();

    unsigned int deviceCount = g_hCoreDeviceCollection->deviceCount();

    return deviceCount;
}
catch (GeneralException& e)
{
    e.what();
    return 3;

}

}
然而,当我在调试模式下通过Visual studio 2015运行LabView时,我遇到了下面的问题,返回到LabView的是catch块中的3

注意:InstanceHandle是一个共享的\u ptr

可以看出,变量是一个空指针,g_hCoreDeviceCollectoin也会发生同样的情况。我想我需要用新命令实例化它,但我有点不确定,因为InstanceHandle是一个共享的ptr


任何帮助都将不胜感激

C++/CLI具有名为的强大功能。您可以在同一代码中(在同一个C++/CLI类中)同时使用托管数据类型和本机数据类型。试着使用C++中直接写在SDK中的对象。

谁是CUMP的下注而不留下任何反馈?这看起来非常像一个有大量支持材料的有效问题。谢谢,我希望得到一些关于他们为什么否决投票的反馈,以便我在将来形成一个更好的问题。Core2代码是否可能无法找到其DLL或依赖DLL之一?您可能希望通过dependency walker Profiler运行LabView,并在代码尝试初始化Core()时查看是否缺少依赖项。另一个建议是创建一个超级基本C++/CLI应用程序,该应用程序加载程序集(DLL)并调用安装对象,然后查看是否有效。如果是这样的话,也许问题是LabView和代码(或核心)之间的交互好主意jschroedl,我将尝试一下。我最后使用它,而只是使用C++ DLL包装器与LabVIEW进行接口,使用了YORDESPECUE(DLLISTUM)。我最终改写了C++ DLL包装器中的代码,它工作正常,只需要手动导出函数(γ-dDeCSPEC(DLLISTUM))。我认为从本地C++到.NET框架到LabVIEW有一个问题。正如其他人暗示的那样,我认为问题在于Labview无法看到依赖的DLL。我将使用dependency walker Profiler查看这是否是问题所在。