Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Type initialization problem in .NET assembly generated by Labview application builder

I am building a .NET assembly from a Labview project using the application builder. I am using Labview 2013 with Visual Express Studio for desktop 2012. After an initial problem with a refnum data type, which I discussed in another thread, it's been going well. However, the .NET assembly has started crashing in Visual studio after I added a few additional VIs in the Labview project. It throws a TypeInitializationException saying "The type initializer for ModDemodAssembly1.LvClient threw an exception" where ModDemodAssembly1 is the .NET assembly that was generated by the application builder. It also says "Failed to call InitLv client function". 

 

What I am compiling is mainly stuff from the modulation toolkit. I started removing one VI at a time from the Labview project to identify which one is causing the problem. The VI that's causing the problem is attached. It only contains MT Resample (complex cluster).vi. It's very simple and I can't see any issues. I am not getting any compile time errors in Labview and Visual Studio. Is there anything special I should do about the VIs from the modulation toolkit? What's confusing is that some other VIs from the modulation toolkit run fine inside the .NET assembly, for example Generate System Parameters.vi and Generate Filter Coefficients.vi.   

0 Kudos
Message 1 of 8
(6,202 Views)

Hi irad,

 

Are you using the .NET Assembly on the development computer? It sounds like a dependency was not included in the assembly build.If you are deploying it to another computer, you would want to have an installer to install all the dependencies. I am not aware of any issues related to teh Modulation Toolkit, but it is possible that the MT Resample (complex cluster).vi has internal dependencies that are not included when the assembly is built.

 

I assume that the VI itself runs in LabVIEW? If you try building another project that contains the MT Resample VI, does it also cause the error? How did you determine that this VI was causing the error (it sounds like you just removed it from the build, is that right)?

Steven Gloor
Staff Customer Engineer - CTA, CLD
0 Kudos
Message 2 of 8
(6,147 Views)

Hi Steven, 

 

Here are answers to your questions: 

 

- Are you using the .NET Assembly on the development computer? 

 

Yes, both Labview 2013 and Visual Studio are installed on the same PC. The PC also controls an NI USRP 2930, but this device has no 

processing capabilites. 

 

I assume that the VI itself runs in LabVIEW?

 

Yes, it runs in Labview.

 

- If you try building another project that contains the MT Resample VI, does it also cause the error?

 

This is a good point. I could try creating a very simple project that only contains MT Resample VI and then I could create a very simple call

in Visual Studio. I could then post both the Labview project and the Visual Studio solution if I still get an exception.

 

- How did you determine that this VI was causing the error (it sounds like you just removed it from the build, is that right)?

 

Yes, the .NET assembly does not work with resample.vi no matter which methods I call. When I remove resample.vi from the build the assembly works. I suspect there are some other modulation toolkit VIs that could cause the same problem, like PSK demodulate, but I haven't carefully verified that yet. 

 

 

0 Kudos
Message 3 of 8
(6,142 Views)

If you are willing, I would suggest creating the simple project to see if that works, that would provide an easy way to reproduce the error if it does.

Steven Gloor
Staff Customer Engineer - CTA, CLD
0 Kudos
Message 4 of 8
(6,133 Views)

I have created a simple project in Labview with only a single file that contains MT Resample.vi. In Visual Studio, I have just created a simple

button which calls the resample VI when pressed. The LV and VS projects are both attached. I still get a type initialization exception.  

0 Kudos
Message 5 of 8
(6,129 Views)

Could you post either a screenshot or a copy of the exact error you are seeing (everything Visual Studio provides), so we can be sure of what you are seeing?

Steven Gloor
Staff Customer Engineer - CTA, CLD
0 Kudos
Message 6 of 8
(6,115 Views)

Attached is the window that comes up when Visual Studio throws an exception. The execution stops since the exception

is not caught. 

0 Kudos
Message 7 of 8
(6,108 Views)

Hi Paul,

 

The error I receive running your sample code indicates that there is a DLL that is failing to load. Specifically an InnerException:

{"Missing Dependency in: Resample1.vi: Library not found or failed to load: nilvamt.dll"}

 

The MT Resample VI is dependent on this DLL. I've looked into the DLL a little more in depth and there appears to be some missing references within it. I've spoken with some of my colleagues, and this appears to be related to the Modulation Toolkit itself, and how it was programmed.

 

I don't know what the bulk of your .NET Assembly actually contains, but there is a .NET wrapper for the Modulation Toolkit. If you are on a tight schedule, it may be useful to you.

Steven Gloor
Staff Customer Engineer - CTA, CLD
0 Kudos
Message 8 of 8
(6,093 Views)