LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

create c# .NET assembly

Hi there,

 

I'm new to C# development. I try to create a .NET assembly in MS Visual C# Express 2010 and try to load it in LV 8.6.

 

The method used in the C# code is public. I've instructed the MS compiler to generate strong names automatically.

 

I've registered the dll with gacutil.

 

When I try to select the library in .NET constructor in LV, the error 

 

"The selected file is not a .NET assembly, type library or automation executable."

 

is thrown.

 

What's wrong ? IS there an othe way to create dlls in C# to load them in LV ? What's the easyest way  to use C# libraries ?

 

Ted

 

0 Kudos
Message 1 of 8
(3,252 Views)

The likely issue is the .NET version. You indicated you're using C# Express 2010. Are you creating a .NET 4.0 assembly? LV 8.6 was not tested with .NET 4.0. While theoretically it should work, reality likes to shatter illusion far too many times in the software world. Can you upload the assembly (just zip it up). I also have C# Express 2010 so if you upload the source I can take a look at that as well.

0 Kudos
Message 2 of 8
(3,247 Views)

Hi smercurio,

 

On the properties tab of the C# .NET development environment, under

 

application -> target framework

 

I've tried 

 

-.NET framework 4 and

- .NET framework 4 client profile

 

with no improving result. I've attached the zip of the entire project.

 

I hope you can help me.

 

Thanks a lot in advance.

 

Ted 

 

0 Kudos
Message 3 of 8
(3,230 Views)

Hi Ted,

 

 This is something I also had to solve.

 

 Is it an option you change the .NET framework to 2 in "application -> target framework

C# .NET development environment,under application -> target framework"

 

I mean, do you use any new .NET features of version 4, that doesn't exists in version 2?

 

In my case it worked.

 

Michael

 

_________________________________________________________________________________________________
LV 8.2 at Windows & Linux


0 Kudos
Message 4 of 8
(3,226 Views)

Hi mishklyar,

 

thanks a lot for your help. Partially, the problem is solved.

 

I've set the .NET framework down to 2.0. The code did first not compile. I had to decomment the

 

using System.Linq

 

include line. After then, it compiled, the assembly was accepted in LV, the function square was visible and callable in an .NET method node.

 

However, this is an restriction. Is there some trick to include this line also ?

 

Best regards,

Ted

 

0 Kudos
Message 5 of 8
(3,223 Views)

Linq (Language Integrated Query) was introduced in .NET 3.5 that's why you had to remove the inclusion of the Linq namespace.

However this is not necessarily a limitation it was just added by default in the C# project. If you don't used methods of that namespace it won't be referenced by the assembly. Otherwise you have to setup your C# project to at least .NET 3.5 which should still work IMO as the CLR was not changed from .NET 2.0 to 3.x. It was first changed with .NET4.0.

You maybe have to setup LabVIEW so that it know's which .NET framework to use.

A lot of good stuff about LabVIEW and .NET you may find on Brian Tyler's blog (unfortunately it is discontinued...)

How to configure LabVIEW you may find here: http://detritus.blogs.com/lycangeek/2005/06/labview_and_net.html -> Picking the .NET Framework

 

Hope this helps

Cheers,

\c

0 Kudos
Message 6 of 8
(3,220 Views)

Dear oenk,

 

thank a lot for the hint, the problem is solved now.

 

I've updated to .NET FW 3.5 and linq can be included.

 

Best regards,

Ted

0 Kudos
Message 7 of 8
(3,218 Views)

@Ted King2 wrote:

Dear oenk,

 

thank a lot for the hint, the problem is solved now.

 

I've updated to .NET FW 3.5 and linq can be included.

 

Best regards,

Ted


If you're not using it, why are you bothering to include it or reference it? You said before that changing the target framework and removing the reference to System.Linq allowed the code to compile, which obviously means you're not using it, or you'd get compilation errors. The only reason why it was there is that, as mentioned, when you create a new project in Visual Studio (2008+) you get that reference added to the project automatically.

0 Kudos
Message 8 of 8
(3,204 Views)