PC Review


Reply
Thread Tools Rate Thread

AmbiguousMatchException when getting property of a contro through reflectionl...

 
 
G.Ashok
Guest
Posts: n/a
 
      10th Nov 2005
Hello,

The Type.GetProperty() method is throwning "AmbiguousMatchException"
when getting value of control class through reflection.


The exception occurs under the following cases.


1. The class is derived from other class
2. Any of the parent class property is either overridden or shadowed in the
derived class
3. and trying to get the property value through reflection of the derived
class.



Which set of BindingFlags should be used in this case ?


Any help on this, is greatly appreciated


Regards,
....Ashok
------------------------------------------------------------------------
"It is beautiful for an engineer to shape and design the same way
that an artist shapes and designs. But whether the whole process
makes any sense, whether men become happier - that I can no
longer decide." - Rudolph Diesel


 
Reply With Quote
 
 
 
 
Carlos J. Quintero [VB MVP]
Guest
Posts: n/a
 
      10th Nov 2005
Try with BindingFlags.DeclaredOnly (IIRC) to get only members declared in
the derived class, not in the base(s) class(es).

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

"G.Ashok" <(E-Mail Removed)> escribió en el mensaje
news:(E-Mail Removed)...
> Hello,
>
> The Type.GetProperty() method is throwning "AmbiguousMatchException"
> when getting value of control class through reflection.
>
>
> The exception occurs under the following cases.
>
>
> 1. The class is derived from other class
> 2. Any of the parent class property is either overridden or shadowed in
> the
> derived class
> 3. and trying to get the property value through reflection of the derived
> class.
>
>
>
> Which set of BindingFlags should be used in this case ?
>
>
> Any help on this, is greatly appreciated
>
>
> Regards,
> ...Ashok
> ------------------------------------------------------------------------
> "It is beautiful for an engineer to shape and design the same way
> that an artist shapes and designs. But whether the whole process
> makes any sense, whether men become happier - that I can no
> longer decide." - Rudolph Diesel
>
>



 
Reply With Quote
 
G.Ashok
Guest
Posts: n/a
 
      10th Nov 2005

Dear Carlos,

Thanks for the suggetion. I already tried it. infact almost every possble
combinations of the BindingFlags but failed to get it. Is there any bug in
CLR etc.?


Regards,
....Ashok
------------------------------------------------------
Make it real or else forget about it -- Carlos Santana



"Carlos J. Quintero [VB MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
| Try with BindingFlags.DeclaredOnly (IIRC) to get only members declared in
| the derived class, not in the base(s) class(es).
|
| --
|
| Best regards,
|
| Carlos J. Quintero
|
| MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
| You can code, design and document much faster.
| Free resources for add-in developers:
| http://www.mztools.com
|
| "G.Ashok" <(E-Mail Removed)> escribió en el mensaje
| news:(E-Mail Removed)...
| > Hello,
| >
| > The Type.GetProperty() method is throwning "AmbiguousMatchException"
| > when getting value of control class through reflection.
| >
| >
| > The exception occurs under the following cases.
| >
| >
| > 1. The class is derived from other class
| > 2. Any of the parent class property is either overridden or shadowed in
| > the
| > derived class
| > 3. and trying to get the property value through reflection of the
derived
| > class.
| >
| >
| >
| > Which set of BindingFlags should be used in this case ?
| >
| >
| > Any help on this, is greatly appreciated
| >
| >
| > Regards,
| > ...Ashok
| > ------------------------------------------------------------------------
| > "It is beautiful for an engineer to shape and design the same way
| > that an artist shapes and designs. But whether the whole process
| > makes any sense, whether men become happier - that I can no
| > longer decide." - Rudolph Diesel
| >
| >
|
|


 
Reply With Quote
 
Larry Lard
Guest
Posts: n/a
 
      10th Nov 2005

G.Ashok wrote:
> Hello,
>
> The Type.GetProperty() method is throwning "AmbiguousMatchException"
> when getting value of control class through reflection.
>
>
> The exception occurs under the following cases.
>
>
> 1. The class is derived from other class
> 2. Any of the parent class property is either overridden or shadowed in the
> derived class
> 3. and trying to get the property value through reflection of the derived
> class.


Could you show us some code that gives this problem? When I construct a
test harness doing what you say, it works fine for me.

--
Larry Lard
Replies to group please

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem setting DisplayIndex property of bound DataGridView contro =?Utf-8?B?RG9u?= Microsoft Dot NET Framework Forms 1 16th May 2006 05:37 PM
AmbiguousMatchException when getting property of a contro through reflectionl... G.Ashok Microsoft VB .NET 3 10th Nov 2005 04:55 PM
How to Create an User Defined Property for a Combo Box User Contro =?Utf-8?B?UHJhYmh1ZGhhcyBQZXRlcg==?= Microsoft VB .NET 2 24th Jan 2005 03:41 PM
URGENTLY PLEASE System.Reflection.AmbiguousMatchException: Se ha encontrado una coincidencia ambigua Luis Esteban Valencia Microsoft ASP .NET 3 7th Sep 2004 04:19 PM
Re: Getting all PropertyInfo objects generating AmbiguousMatchException Mattias Sjögren Microsoft C# .NET 1 14th Aug 2003 07:08 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:55 AM.