Jump to content

LabVIEW built .NET assembly works ok when built using LV2019 but not LV2020


Recommended Posts

Recently I have tried to package up some code as a .NET Assembly. I managed to pack some pretty complicated LV2019 code (including some LabVIEW classes and dynamically called code) into an assembly and was able to call it just fine from a simple C# console application. However, this does not work when I moved over to LV2020.

To make things simple to try and get to the root of it I created the simplest possible example I can think of. One copy is in LV2019 and it works fine, the other is LV2020 and it does not work.

The assembly builds fine in LV2020, and indeed is callable from LabVIEW code. The test is just a simple Increment VI.

 

image.png.6cbf4a348e52241532df9decb10b676f.png

image.png.ea581cfdf9e39bff3ac5306e028d7079.png

This works fine when the assembly is built using LV2019, the num variable is correctly 2 after running this line of code.

However in LV2020 I get the following exceptions after running that line

System.TypeInitializationException
  HResult=0x80131534
  Message=The type initializer for 'MyAssemblyNamespace.LvClient' threw an exception.
  Source=Increment2020
  StackTrace:
   at MyAssemblyNamespace.MyTestClass.Increment(Double input)
   at Increment.Program.Main(String[] args) in C:\dev\Scratch\DLL Build Test (2020)\Source\C#\Increment\Increment\Program.cs:line 10

Inner Exception 1:
FileNotFoundException: Missing Dependency in:

Inner Exception 2:
VIAssemblyException: Missing Dependency in:

I have tried playing around with including the LabVIEW Interop assembly in the C# application (C:\Program Files (x86)\National Instruments\Shared\LabVIEW Run-Time\2019\NationalInstruments.LabVIEW.Interop.dll) and changing this to 2020 for the LV2020 version, it does not seem to make any difference.

The LV2019 version runs without this assembly included in the project.

Is this something to do with the GAC? This is now getting into the details of .NET that I am not really very familiar with.

Does anyone have any tips for things I can look into? I have attached a zip of everything for anyone curious.

 

Build Test.zip

Link to comment

A bit more information.

According to the Dependencies application the LV2020 also has a dependency on this System.dll that is located in the GAC.

image.png.f8825b79bb3b1946a8ac72a5f75462cd.png

I have tried copying that DLL to various locations (I think I am not supposed to because this is system stuff!) but it still gives me the same error.

 

Edited by Neil Pate
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.