LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

System.InvalidOperationException with 3rd party .NET Assembly

Greetings All,

 

One of our clients has developed a fairly elaborate .NET component that needs to be integrated into a LabVIEW application.

 

I put together a simple VI to test connectivity and inspect the available propeties. (To underscore the simplicity of this test VI , here are the construction steps: I dropped an instance of the .NET constructor node into a blank VI, then linked it to .dll supplied by the customer. I selected the appropriate constructor within this .dll, using the NI dialog, and wired it to a .NET property node.)  

 

My first run attempt produced an error dialog stating, "The selected file is not a .NET assembly, type library, or automation executable. "


Searching for this error on the NI website produced an application note indicating that a .NET configuration file named "LabVIEW.exe.config", is required to load the correct CLR. From the application note:

 

"LabVIEW employs a set of default behaviors to determine which version of a particular .NET assembly to reference and which version of the Common Language Runtime (CLR) to load. You can create a .NET configuration file to override the default ways that LabVIEW loads the CLR."

 

The application then specifies the following:

 

The configuration file needs to be placed next to LabVIEW.exe and be named LabVIEW.exe.config. The following example will instruct LabVIEW to load the CLR 4.0:

<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0.30319"/>
</startup>
</configuration>


 

I'm not sure if it's relevant, but the .NET component also requires a .NET configuration file of it's own. Therefore, I added the lines specified above to the original .NET configuration file (supplied with the .dll). I renamed the edited config file to "LabVIEW.exe.config", and put it into the LabVIEW 2010 directory next to LabVIEW.exe.

 

Now, when I run my test VI, the constructor node returns Error 1172 -- an error creating instance of the selected constructor in the selected assembly.

 

The error message also specified thsi Inner Exception: System.InvalidOperationException: The key 'BDLib TraceFront:' does not exist in the appSettings configuration section.

 

A reference to the specified key ('BDLib TraceFront'), is included in the config file delivered by the customer, but LabVIEW doesn't appear to have access to this information, even though it is included in the "LabVIEW.exe.config" file. It appears that changing the config file as NI specifed (in the application note) enables LabVIEW to recognize the .NET assembly, but the assembly itself doesn't appear to be getting what it needs from the "modified, hybrid" config file.   

 

Is there some way to modify the config file so that the pertinent information is available to both LabVIEW and the .NET component? Alternatively, is it possible to use two separate config files? If not, what is the right way to proceed.

 

(Disclaimer: I am new to .NET integration, so please excuse my lack of depth in this area.)

 

Thanks.  

0 Kudos
Message 1 of 6
(3,425 Views)

I have encountered this issue outside of the Labview and it is an issue with .Net support on a particular OS. Not all OS are supported by all versions of .Net. Find out what versionof .Net the assembly is targetting and then look for support of .Net x.x on that OS. Be sure to read the fine print because usually it is an exception to support, for instance a version my support XP but not XP Server versions.

Fred Loveless
Kepware Technologies
http://www.kepware.com
0 Kudos
Message 2 of 6
(3,419 Views)

Hi All,

 

After trying a few things, I was able to find a solution. I thought it was worth posting here in case someone else has this same difficulty.

 

It seems to work with two config files:

 

1) "LabVIEW.exe.config", as suggested in the NI application note, and 

2) [LVprojectName].lvproj.config

 

(Of course, you will need to substitute the name of your own project in for [LVprojectName].)

 

LabVIEW.exe.config goes into the LabVIEW directory with LabVIEW.exe. The Project config file resides in the same folder as your project. (If you are building an executable, I believe the config filename will need to change to [yourapp].exe.config)

 

If there is a way to do this with only one config file, I was not able to find it. However, by using two config files as outlined here. it seems to work!

 

Cheers!

 

Message 3 of 6
(3,415 Views)

i am using Labview 2013 ,in which .net is used for a paint brush in vi but during runtime, error showing as attached below.image001.jpg

0 Kudos
Message 4 of 6
(3,014 Views)

Hi shilpawalia,

 

Error 1172 is a very generic error message for any .NET exception in LabVIEW. It seems like an invoke node within your Opacity Trace VI is calling a method that is already being used. Can you upload this VI?

 

Best,

Eric

Applications Engineering

National Instruments

0 Kudos
Message 5 of 6
(2,995 Views)

I am attaching a VI in which error is coming. Check it and tell me if you can find a solution for that.

0 Kudos
Message 6 of 6
(2,916 Views)