Neil Pate Posted July 15, 2021 Report Share Posted July 15, 2021 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. 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 Quote Link to comment
Neil Pate Posted July 15, 2021 Author Report Share Posted July 15, 2021 (edited) 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. 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 July 15, 2021 by Neil Pate Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.