NI VeriStand

Showing results for 
Search instead for 
Did you mean: 

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

Go to solution

My Code:


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



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.



Message=The type initializer for 'NationalInstruments.VeriStand.StimulusProfileDefinitionApi.StimulusProfile' threw an exception.
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

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

Hi tyk007


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


0 Kudos
Message 3 of 9

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

Piotr F.
Hardware Engineer @ ZF
0 Kudos
Message 4 of 9


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


0 Kudos
Message 5 of 9

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
Accepted by topic author ngupta4


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


Message 7 of 9



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?



0 Kudos
Message 8 of 9

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