NI VeriStand

cancel
Showing results for 
Search instead for 
Did you mean: 

NI VeriStand scripting with C#: Error- System.TypeInitializationException

Solved!
Go to solution

My Code:

 

private StimulusProfile ExecuteStimulusProfile()
{
Console.WriteLine("Checking for compile-time errors...");
StimulusProfile stimulusProfile = new StimulusProfile(m_stimulusProfileFilePath);\

}

where 

stimulusProfile = "C:\\Users\\ngupta\\Documents\\VeriStand Projects\\Engine Demo\\Stimulus Profiles\\Basic Engine Demo\\Engine Demo Basics.nivsstimprof"

which is a valid path to the Stimulus Profile.

 

Error:

System.TypeInitializationException
HResult=0x80131534
Message=The type initializer for 'NationalInstruments.VeriStand.StimulusProfileDefinitionApi.StimulusProfile' threw an exception.
Source=NationalInstruments.VeriStand.RealTimeSequenceDefinitionApi
StackTrace:
at NationalInstruments.VeriStand.StimulusProfileDefinitionApi.StimulusProfile..ctor(String file)
at AutoVeristand.VeristandExecution.ExecuteStimulusProfile() in C:\Users\ngupta\source\repos\AutoVeristand\AutoVeristand\VeristandExecution.cs:line 99
at AutoVeristand.VeristandExecution.Start() in C:\Users\ngupta\source\repos\AutoVeristand\AutoVeristand\VeristandExecution.cs:line 56
at AutoVeristand_TestApp.RunVeristand.Start(String[] args) in C:\Users\ngupta\source\repos\AutoVeristand\AutoVeristand_TestApp\RunVeristand.cs:line 46
at AutoVeristand_TestApp.Program.Main(String[] args) in C:\Users\ngupta\source\repos\AutoVeristand\AutoVeristand_TestApp\Program.cs:line 22

Inner Exception 1:
FileNotFoundException: Could not load file or assembly 'NationalInstruments.VeriStand.Internal, Version=2018.0.0.0, Culture=neutral, PublicKeyToken=a6d690c380daa308' or one of its dependencies. The system cannot find the file specified.

 

VeriStand Version on machine - 2020

 

Please help me resolve this? 

I'm very new to Visual Studio, NI Veristand, C#

 

Thank you!

0 Kudos
Message 1 of 9
(348 Views)

I'm not familiar with VeriStand but this part of the exception message stood out to me:

 

FileNotFoundException: Could not load file or assembly 'NationalInstruments.VeriStand.Internal, Version=2018.0.0.0, Culture=neutral, PublicKeyToken=a6d690c380daa308' or one of its dependencies. The system cannot find the file specified.

I assume that the file does exist on disk? It does seem odd that you mention Veristand 2020 but the assembly is referencing "2018.0.0.0" (implying its for Veristand 2018). Perhaps make sure you are referencing the latest version that you have on your PC (perhaps "2020.0.0.0") in your project references in Visual Studio.

0 Kudos
Message 2 of 9
(309 Views)

Hi tyk007

 

I tried changing the version to 2020 but that is not working.

 

0 Kudos
Message 3 of 9
(293 Views)

Indeed, the problem is in the assembly version - your code tries to load 2018 version. Correct assembly version for 2020 is "8.0.0.0" - NI changed the versioning scheme in Veristand 2019.

Piotr F.
Hardware Engineer @ ZF
0 Kudos
Message 4 of 9
(268 Views)

Hi,

Try to change the "specific version" to false in your project references for VeriStand so it resolves to the current registered assemblies.

Regards

0 Kudos
Message 5 of 9
(261 Views)

I imported the latest dll from the Veristand 2020.

 

Which has resulted in the below errors:

 

I'm also attaching my .NET version details which I'm using to run my code. 

 

Please help.

Download All
0 Kudos
Message 6 of 9
(246 Views)
Solution
Accepted by topic author ngupta4

Hi,

Your Veristand.ClientApi has a 2018 version, maybe its a mismatch. Try remove the reference and set it back from the 2020 ClientApi.

Regards

Message 7 of 9
(233 Views)

Hi,

 

I have the same error and I am on Veristand 2018 SP1, the NationalInstruments.Veristand.ClientAPI file seems missing from disk. What is a possible solution for this? I cannot find any resources online to get the file back on disk. Do I have to reinstall? Would reinstalling affect any of my projects that I have currently?

 

Thanks.

0 Kudos
Message 8 of 9
(133 Views)

Hi siddeshk,

 

Error 1: Exception thrown: 'System.TypeInitializationException' in AutoVeristand.dll

An unhandled exception of type 'System.TypeInitializationException' occurred in AutoVeristand.dll

The type initializer for 'NationalInstruments.VeriStand.StimulusProfileDefinitionApi.StimulusProfile' threw an exception.

Resolution Steps:

If the Veristand version is different that what is specified in the document, please follow the below steps:

 

  1. In the Solution Explorer navigate to the References Tab and look for the dependent dll’s required to run the project and keep a note of it.
  2. Delete the NationalIntrument.<> dll’s.
  3. After deleting, check the Resources folder, if the consecutive dll’s are not deleted, manually delete them (Make a note of what you’ve deleted)

 

  1. An updated and compatible version of the dll must be configured

Go to the below file path for the updated dll’s of the Veristand Version installed.

C:\Program Files (x86)\National Instruments\VeriStand 2020

 

  1. Copy the dll’s and paste it on the folder path under Resources.
  2. Close the project and re-open it on Visual Studio. The Resources folder will contain the updated dll and the References tab is auto populated with the updated dll’s.
0 Kudos
Message 9 of 9
(100 Views)