-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Reflection and calling InvokeMember fails
PostPosted: Wed Sep 21, 2005 8:07 pm 
I am having problems using reflection on my objects that are tied in with NHibernate. Basically, I have a "Customer" object that has a property of "Name", when inspecting the object in the debugger it seems that the method is actually "get_Name".

When I call invokeMember(with all of the binding flags I could think of) it keeps throwing a no member found exception. I have tried "get_Name" and "Name" but no luck.

Does anyone know how to get to this to work?


Code:

ListView lvi = new ListView();

lvi.Text = t.InvokeMember(
"get_Name",
BindingFlags.Default,
null,
obj,
null);


Top
  
 
 Post subject:
PostPosted: Wed Sep 21, 2005 8:39 pm 
Ah, looks like I goofed...

The correct flags are
BindingFlags.DeclaredOnly |
BindingFlags.Public | BindingFlags.NonPublic |
BindingFlags.Instance | BindingFlags.GetProperty

and in my case you can call the Name property.


Top
  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.