-->
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.  [ 4 posts ] 
Author Message
 Post subject: Proxies and Reflection
PostPosted: Sun Jan 06, 2008 7:40 am 
Contributor
Contributor

Joined: Sun Jun 26, 2005 5:03 am
Posts: 51
Location: London, UK
I changed a couple of my classes to lazy load, but now have a problem due to the proxies and was wondering if anyone else had come across this.

I have two classes Contact and Person. Contact contains a property Title, which is now declared virtual, and Person just uses it.

I also have some domain validation rules, which use reflection to get at the data, and here is where the problem lies.

When I try to locate the Title property via reflection, I get an AmbiguousMatch error, as the proxy for both Contact and Person have a Title property. This seems to me to be a bug in the proxy generation as I can't transparently replace the class with the proxy at the moment without knowing that the proxy is there?

I've tried it with reflection optimizer set to both true and false.

Any ideas?

_________________
Paul Hatcher
NHibernate Team


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 06, 2008 12:52 pm 
Expert
Expert

Joined: Tue Aug 23, 2005 5:52 am
Posts: 335
I seem to remember that there's a way to tell reflection only to look at the current instance and not the whole inheritance hierarchy. Look for a binding flags overload on the GetProperty method I think...

Cheers,

Symon.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 07, 2008 6:16 am 
Contributor
Contributor

Joined: Sun Jun 26, 2005 5:03 am
Posts: 51
Location: London, UK
On the POCO object, Title *is* in the inheritance hierarchy as it's defined by Contact; Person merely inherits from it.

So the issue is to do with how the proxy is constructed I believe; I'm going to ask some questions on Castle to see if there's a solution.

Regards

_________________
Paul Hatcher
NHibernate Team


Top
 Profile  
 
 Post subject: Proxies and Reflection
PostPosted: Tue Jan 08, 2008 5:46 am 
Senior
Senior

Joined: Thu Jun 21, 2007 8:03 am
Posts: 127
Location: UK
Hi Paul,

I had this before. It turns out it's a bug in the .Net Framework 2.0. SP1 has a fix, but requires a code change (in Dynamic Proxy) to implement it. The Castle team have made this change, but I don't think it will make it into NHibernate until version 2.0.

There were also workarounds suggested in the oroginal posts:
http://forum.hibernate.org/viewtopic.php?t=961306
http://forum.castleproject.org/viewtopic.php?t=3145

Cheers,
Richard


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.