0

我有一个用 C++ 编写的 .NET 类库。“public ref class MyClass”定义了一个方法“MyMethod”,它采用两个 System::Int32 参数。

这是 MyClass 首先是我的问题:

namespace MyNetAssembly {    
    public ref class MyClassThatDoesStuff
    {
    public:
        MyClassThatDoesStuff();

        void MyMethod(System::Int32^ number1, System::Int32^ number2);
        property System::Int32 MyProperty{
            int get (){
                return *_result;
            }

            void set(System::Int32 value){
            }
        }
    private:
        int^ _result;
    };
}

这是cpp代码:

MyNetAssembly::MyClassThatDoesStuff::MyClassThatDoesStuff()
{
    *_result = 0;
}

void MyNetAssembly::MyClassThatDoesStuff::MyMethod(System::Int32^ number1, System::Int32^ number2)
{
    *_result =(*number1 + *number2) * 100;
}

当我使用“构造器节点”从 LabView 8.5 加载这个程序集时 vi。然后,我尝试使用“调用方法”vi 调用 MyMethod(),我将方法的参数设为“ValuteType”而不是“Int32”,因为我希望直接与 LabView 常量和控件一起使用。相反,当我通过右键单击参数的连接器创建常量时,我​​得到“.NET 对象”!

请问,如何让 LabView 识别参数类型?

注意:我尝试将参数从更改System::Int32^ number1System::Int32 number1. 那也没有帮助。

4

1 回答 1

0

我想我明白了!显然,vi 文件本身发生了一些有趣的事情。如果存在已定义程序集的 .NET构造器节点,则在 Visual Studio 中重新构建程序集并更新构造器节点不会影响导入的方法签名。因此,MyMethod(System::Int32 number1, System::Int32 number2, System::String^ str)没有被看到。

所以,对我有用的是以下内容:

  1. 我从 vi 中删除了 *Constructor Node* 和 *Invoke Node*,然后保存。
  2. 将整数值传递到MyMethode这里是对我有用的方法定义:
    MyMethod(System::Int32 number1, System::Int32 number2, System::String^ str)
    
    我认为我在 LabView 中看到的“ValueType”术语意味着它需要 Int32 的值类型。

当 LabView 让您认为它在您重建您的 .NET 程序集时已经完全自我更新时,您可能会感到困惑。

感谢所有帮助过的人。我希望我的回答对使用 .NET 和 LabView 的其他人有所帮助。

于 2010-11-02T12:19:55.480 回答