取消
显示结果 
搜索替代 
您的意思是: 

How to use a .NET assembly generated in Matlab

已解决!
转到解答

I'm new to using .NET Assemblies in Labview. I generated a dll in Matlab, and then  used a "constructor" to point to that Matlab dll.  I then connect that to an "invoke node" which seems to correctly know all the inputs to the function "Setup" contained in the dll. The problem is that the inputs should be all numerical arrays and instead show up in Labview as .NET refnums which cant be wired up. The output of the "Setup" function is also several arrays, but in Labview shows up as a single output. What am I missing here?

0 项奖励
1 条消息(共 21 条)
4,828 次查看

Posting the .NET assembly would be helpful to give you some more pointed advice.

 

But from your description I can guess that parameters for the Setup function are not the Array type but of a different type such as ArrayList, IEnumerable<T> or one of the other collection classes / generic collections.

 

Also in .NET there are only two ways of returning information - via the reference modifiers (called "ref" and "out" in C#) or via the return value of the method. It looks like your Setup method only has a single return value but of what type I can't say without the assembly on hand.

0 项奖励
2 条消息(共 21 条)
4,826 次查看

You could try one or both of these options:

 

Create arrays in NET.png

 

The "Double" and "Array" types are in the "mscorlib" assembly.  "To .NET object.vi" is in the ".NET" palette.

3 条消息(共 21 条)
4,803 次查看

Kyle,

I tried your second suggested method, but get an error message. Any further suggestion? Meanwhile I'll try your first method. I appreciate your help.

0 项奖励
4 条消息(共 21 条)
4,769 次查看

Kyle,

 

Meanwhile which "object" in the mscorelib contains the "double" and "array" constructors that you used in your first example? There is a lot in that library. Thanks.

0 项奖励
5 条消息(共 21 条)
4,766 次查看

Look under "System" and you will find those classes.

0 项奖励
6 条消息(共 21 条)
4,764 次查看

Tyk007,

 

All the input parameters to the "Setup" method show up as "MWArray" in the pull-down menu for selecting the method for the class. I assume this is because Matlab is a  MathWorks (MW) product, and Matlab was used to create the .NET assembly. Is there something special I need to do? The Setup function in Matlab returns several arrays, and I want all of them when I invoke the method in Labview.

0 项奖励
7 条消息(共 21 条)
4,763 次查看

Tyk007,

I found "double in "system", however "array" is problematic.

0 项奖励
8 条消息(共 21 条)
4,762 次查看

If you re-check Kyle97330's post the Array is created using a static method on Array. Check that you aren't trying to find a constructor and a browsing for an Invoke node.

0 项奖励
9 条消息(共 21 条)
4,754 次查看

@Rogueone wrote:

Tyk007,

 

All the input parameters to the "Setup" method show up as "MWArray" in the pull-down menu for selecting the method for the class. I assume this is because Matlab is a  MathWorks (MW) product, and Matlab was used to create the .NET assembly. Is there something special I need to do? The Setup function in Matlab returns several arrays, and I want all of them when I invoke the method in Labview.


I'm not familiar with Matlab's .NET assembly creation functionality so I would assume that the "MWArray" type exposes some properties and methods to help you access the individual elements. Posting your .NET assembly (try zipping it) would make it easier for me to help you.

0 项奖励
10 条消息(共 21 条)
4,752 次查看