LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

System.Reflection.TargetException

Hello I'm currently trying to translate a C# code into labview (joined vi is strictly the reflect of this code). I get the "System.Reflection.TargetException" error in the "Impersonate" method of my WindowsIdentity object. I've also tried to use the static "Impersonate" method with the same effect. I thought it was a security issue but if I call (from labview) the inital code in my .NET assembly it works.

 

Any idea ?

Download All
0 Kudos
Message 1 of 5
(2,783 Views)

Hi,

 

Please, find some links about calling C code into LABview.

 

https://decibel.ni.com/content/docs/DOC-9069 Tutorial: Configuring the Call Library Function Node to call a Simple DLL

https://decibel.ni.com/content/docs/DOC-9079 Calling C/C++ DLLs Containing Simple and Complex Datatypes from LabVIEW

 

I didn't find any reason for your error.

 

Maybe if you call a .DLL with your code C into LABview, it should work.

 

Hope it helps.

 

MatthieuR

0 Kudos
Message 2 of 5
(2,733 Views)

Hello,

 

The problem is not on the C DLL call since this part works fine, but it's when calling a .NET object method. As it works when it's called from inside a .NET assembly called from LabVIEW I would supose it is due to the way LabVIEW calls the .NET code. I guess it's using the reflection along with Invoke methods to do that, explaining the System.Reflection.TargetException, but I wonder why it fails precisely for the concerned method as the other method of that class are called normaly. Furthermore the reflection seems ok because the method appears in the browser while configuring the "invoke node" function.

0 Kudos
Message 3 of 5
(2,722 Views)

Hi,

 

Can you try this VI, I changed a bit the structure condition with your "dispose" method.

 

Hope it could help.

 

Regards,

 

MatthieuR

0 Kudos
Message 4 of 5
(2,700 Views)

It makes no difference at my side. Your change is a potential bug correction, but I still get the System.Reflection.TargetException. I've tryed on another computer with both LabVIEW 11 & 12 with the same issue. Does the impersonation really work on your side ?

0 Kudos
Message 5 of 5
(2,690 Views)