Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Type Initializer for 'Module' threw an exception

I'm a first time user of Measurement Studio and the M-Series Daq.  I'm using the NI-6229.  I wrote a simple program that will control 8 valves with DIO from the Daq.  For each valve I there is either an On button or an Off button.  I ran it and it worked fine, all 8 pins outputted either 5 or 0 volts as they should.  I saved it and closed the program and when I reopened it the next day and ran it without changing any code I got the following error when clicking one of the buttons:
 
Type Initializer for '<Module>' threw and exception.
 
I even tried just copying and pasting the program into a new project and it performed the same, it worked until I closed and reopened VS.Net.  What would cause it to not run after closing and reopening it?
0 Kudos
Message 1 of 7
(10,775 Views)

Hello,

Just a couple quick questions to try and narrow down the scope of the problem.  What versions of Measurement Studio and Visual Studio are you using?  If you run a sample program (found at C:\Documents and Settings\All Users\Documents\National Instruments\NI-DAQ\Examples\DotNETx.x\Digital\Generate Values) and then save it after execution does it give you the same problems? Are you using one specific type of control? If so try modifying the example (after re-saving to a new directory) with one of these controls to see if it will reproduce the behavior.  Basically we want to try and narrow it down to see if its the control or the DAQmx code that is creating the problem.  Usually initialization errors are cause by structs, classes, or other complex data structures that aren't properly created during execution.  Unfortunately from your brief description its hard to tell which part of the program is causing the error, even though it seems like its tied to the controls.

If your program is fairly simple, you can feel free to post the files (in zip format) on the forum and I will be more than happy to test them and see if I can reproduce this odd behavior you are seeing.

John B.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 7
(10,758 Views)
Thank you for the response.  Sorry I have been on vacation and not by a computer.  I wont be in the office until tomorrow so I can post the code then. But off the top of my head I'm using VIsual Studio.NET 2005 and I think the latest version of Measurement Studio but I'm not positive.  I will post the info tomorrow when I get back to my office.
0 Kudos
Message 3 of 7
(10,712 Views)
Ok I'm using Measurement Studio 8.1.  I've attached the a zip of the program below.
0 Kudos
Message 4 of 7
(10,705 Views)
And also I don't know if this helps but when I built it I recieved the error "Found Conflicts Between Different Versions of the Same Dependent Assembly".  I tried it with doing the fix it recommends and without doing and the result was still the same. 
0 Kudos
Message 5 of 7
(10,693 Views)

Ok I got it figured out, the directory I was saving the project to was bad so I got it to work after saving it to a different directory. 

Thanks

Jerrad

0 Kudos
Message 6 of 7
(10,667 Views)

Jared,

I'm glad you were able to figure out the problem.  I had tried to reproduce your problem yesterday (with your code) without success so I was going to try again today but it looks like you were able to figure it out before I got back to it.  I think the conflict error you mentioned in the previous post hints at a problem with the files in the project so this resolution makes sense. 

Feel free to post again in the future if you run into more problems.

John B.
Applications Engineer
National Instruments
0 Kudos
Message 7 of 7
(10,658 Views)