From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

calling .net assembly with an interface parameter

I'm trying to call a compiled .net assembly from Labview.  The constructor defines as an input parameter an object that is a C# interface. This means I can't call a constructor to create the object.

 

Is it possible to use this DLL or am I stuck without making C# code changes?  I've posted the constructor definition and the interface defintion.  I'm trying to construct SampleClass.

 

public SampleClass(string InstrumentName, ISampleInterface interfaceobject 😞 BaseClass(InstrumentName, interfaceobject)

 

public interface ISampleInterface : ISampleInterfaceParm, ISampleInterfaceData, ISampleInterfaceUi
{
}

 

Thanks so much!

 

0 Kudos
Message 1 of 3
(2,482 Views)

@drummaniac83 wrote:

I'm trying to call a compiled .net assembly from Labview.  The constructor defines as an input parameter an object that is a C# interface. This means I can't call a constructor to create the object.

 

Is it possible to use this DLL or am I stuck without making C# code changes?  I've posted the constructor definition and the interface defintion.  I'm trying to construct SampleClass.

 

public SampleClass(string InstrumentName, ISampleInterface interfaceobject 😞 BaseClass(InstrumentName, interfaceobject)

 

public interface ISampleInterface : ISampleInterfaceParm, ISampleInterfaceData, ISampleInterfaceUi
{
}

 

Thanks so much!

 


An interface, by definition, cannot be created. You can't create an instance of one in C# (or any .NET language) either. What you do create an instance of is a class that implements this interface. 

 

In your example SampleClass constructor requires, as an argument, a class that implements the ISampleInterface interface. Presumably you have class(es) that implement this interface and an instance one of those classes is what you will pass to the constructor. 

 

LabVIEW supports this method of construction - provide to this argument an instance of the class that implements the interface.

0 Kudos
Message 2 of 3
(2,454 Views)

@tyk007 wrote:

An interface, by definition, cannot be created. You can't create an instance of one in C# (or any .NET language) either. What you do create an instance of is a class that implements this interface. 

In your example SampleClass constructor requires, as an argument, a class that implements the ISampleInterface interface. Presumably you have class(es) that implement this interface and an instance one of those classes is what you will pass to the constructor. 

LabVIEW supports this method of construction - provide to this argument an instance of the class that implements the interface.


tyk007 thanks so much.  I discussed it with a coworker and evidently they had classes implemented for the interface.  Just had to look in a different source file.

 

Thanks for the descriptive definition and not shunning me for my ignorance.

 

Josh

0 Kudos
Message 3 of 3
(2,418 Views)