03-15-2018 02:52 AM - edited 03-15-2018 02:55 AM
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
Solved! Go to Solution.
03-15-2018 08:00 AM
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.
03-15-2018 08:40 AM - edited 03-15-2018 08:44 AM
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.
03-15-2018 08:57 AM
@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: GlobalDomainUser name: dawid.xxx@gmail.com
Yes, but I'm not in a domain...
03-15-2018 08:58 AM
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.
03-15-2018 09:45 AM
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?
03-16-2018 03:01 AM
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.
03-16-2018 03:54 AM
@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.