LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

.Net - Get user mail from domain controller - Problem with .net object

Solved!
Go to solution

Hi all,

 

I'm struggling to understand why I'm getting the error msg in my simple VI, which should return the mail adress from domain controller for specified user. I have problem with .net object, but I cannot understand why. I will be gratefull for any help.

 

Error code: 1172

Error msg: Invoke Node System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 Inner Exception: System.Reflection.TargetException: Object does not match target type. <append><b>System.Reflection.TargetException</b> in Get_mail.vi

0 Kudos
Message 1 of 8
(3,034 Views)

I can't get that far in your example (no idea what domain I should fill in).

 

What I get from propertyInfo.GetValue, is that object can be null:

object o = propertyInfo.GetValue(myObject, null);

 

Have you tried to wire a constant to obj? That should be a null object.

0 Kudos
Message 2 of 8
(2,998 Views)

Hi,

 

In my company I just put our domain name and my user name in domain, but it will not work in your computer. You have to be in domain and try to use your user name. Example:
Domain name: GlobalDomain

User name: dawid.xxx@gmail.com

 

You cannot leave the obj not connected, you cannot connect constant:( You will get error anyway. I'm really doubt how to deal with it, and where to find a help:(

With constant connected, error msg:
Error 1172 occurred at Invoke Node System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 Inner Exception: System.Reflection.TargetException: Non-static method requires a target.

 

0 Kudos
Message 3 of 8
(2,994 Views)

@dakot wrote:

 

In my company I just put our domain name and my user name in domain, but it will not work in your computer. You have to be in domain and try to use your user name. Example:
Domain name: GlobalDomain

User name: dawid.xxx@gmail.com


Yes, but I'm not in a domain...

0 Kudos
Message 4 of 8
(2,985 Views)

In stead of GetValue, I'd try GetType. It won't solve anything directly, but knowing the expected type might get you further. Use ToString to convert the returned type to a readable format.

0 Kudos
Message 5 of 8
(2,984 Views)
Solution
Accepted by topic author dakot

BTW. UserPrinciple has an EmailAddress propertry. If all you want is the email address, why go through the properties?

 

Also, I think the object needs to be the object you're querying about. Could that be the UserPrinciple object?

0 Kudos
Message 6 of 8
(2,981 Views)

wiebe@CARYA wrote:

BTW. UserPrinciple has an EmailAddress propertry. If all you want is the email address, why go through the properties?


Yes, That's the solution. I can get what I need from there:) Thanks. I did not thought about that. So simple:)

 


wiebe@CARYA wrote:

Also, I think the object needs to be the object you're querying about. Could that be the UserPrinciple object?


Good comment, I think the same, but where to find the answer, what exactly the "GetValue" command needs? You cannot connect reference to obj input.

0 Kudos
Message 7 of 8
(2,968 Views)

@dakot wrote:

wiebe@CARYA wrote:

Also, I think the object needs to be the object you're querying about. Could that be the UserPrinciple object?


Good comment, I think the same, but where to find the answer, what exactly the "GetValue" command needs? You cannot connect reference to obj input.


 A lot of the problems with using .NET from LabVIEW come from the fact that C# does them automagically. So the conversion from reference to obj could simply be done by the C# language. Things like this (I thing the entire property construct might be handled under the hood by C#) can make it very hard to find documentation or examples.

 

I've used the C# compiler that is available in .NET to build assemblies to do C# stuff. I don't like to do it, as it should be possible from LabVIEW, but some things are simply not possible in LabVIEW at the moment. For instance overwriting class members in a child class. That is a pretty normal thing in some corners of .NET.

0 Kudos
Message 8 of 8
(2,960 Views)