It has more to do with Aspect# creating multiple, same-name Properties; but Aspect# or not, developer can create new “same name” property as demonstrate in this blog:

http://blogs.msdn.com/thottams/archive/2006/03/17/553376.aspx

 

The proper way to do it would be:

 

System.Type targetType = _targetType;

System.Type objectType = typeof(Object);

PropertyInfo propertyInfo = null;

 

while (propertyInfo == null)

{

            propertyInfo = targetType.GetProperty(propertyName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly );

           

targetType = targetType.BaseType;

 

            if (targetType.Equals(objectType)) break;

}

 

But I did a quick fix and lazily came up with this:

            PropertyInfo propertyInfo = _targetType.GetProperty(propertyName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly );

if (propertyInfo == null)
    propertyInfo = _targetType.GetProperty(propertyName);

 

I’ve updated the presentation Blogs.zip, see error detail of the test method: ObjectPersisterWithMicrosoftAccessTestProxy

 

http://www.noogen.net/download/free/Blogs.zip

 

Error Message:

 

Test method Rels.Data.Test.ObjectPersisterTest.ObjectPersisterWithMicrosoftAccessTestProxy threw exception:  IBatisNet.DataAccess.Exceptions.DataAccessException: Error executing SELECT query 'BlogSelect'.  Cause: Could not Set property 'Author' for CProxyTypeBlogBusinessObjects_IIsProxy_ISerializable2.  Cause: Ambiguous match found. --->  IBatisNet.Common.Exceptions.ProbeException: Could not Set property 'Author' for CProxyTypeBlogBusinessObjects_IIsProxy_ISerializable2.  Cause: Ambiguous match found. --->  System.Reflection.AmbiguousMatchException: Ambiguous match found..

 

Error Stack Trace:

    at System.RuntimeType.GetPropertyImpl(String name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers)

   at System.Type.GetProperty(String name)

   at IBatisNet.Common.Utilities.Objects.Members.DelegatePropertyGetAccessor..ctor(Type targetObjectType, String propertyName) in E:\Projects\ibatis\mapper\IBatisNet.Common\Utilities\Objects\Members\DelegatePropertyGetAccessor.cs:line 64

   at IBatisNet.Common.Utilities.Objects.Members.GetAccessorFactory.CreateDynamicPropertyGetAccessor(Type targetType, String propertyName) in E:\Projects\ibatis\mapper\IBatisNet.Common\Utilities\Objects\Members\GetAccessorFactory.cs:line 112

   at IBatisNet.Common.Utilities.Objects.Members.GetAccessorFactory.CreateGetAccessor(Type targetType, String name) in E:\Projects\ibatis\mapper\IBatisNet.Common\Utilities\Objects\Members\GetAccessorFactory.cs:line 261

   at IBatisNet.Common.Utilities.Objects.ObjectProbe.GetMember(Object obj, String memberName, AccessorFactory accessorFactory) in E:\Projects\ibatis\mapper\IBatisNet.Common\Utilities\Objects\ObjectProbe.cs:line 414

 

 

Thanks,

 

Tom Nguyen

Sr. Developer

tom.nguyen@rels.info


From: Gilles Bayon [mailto:ibatis.net@gmail.com]
Sent: Thursday, May 25, 2006 12:41 PM
To: user-cs@ibatis.apache.org
Subject: Re: Hey Guys - Another IBatisNet Demo App for VS.NET2005

 

I have done a unit test with a property override by new and haven't be able to redo your issue.

Could you give me a unit test which fails for the current code.

 

Thanks

-Gilles

And DlegatePropertyGetAccessor.cs( line 64 ) and DelegatePropertySetAccessor (line 65):

From:

            PropertyInfo propertyInfo = _targetType.GetProperty(propertyName);

 

To:

            PropertyInfo propertyInfo = _targetType.GetProperty(propertyName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly );

 

            if (propertyInfo == null)

                propertyInfo = _targetType.GetProperty(propertyName);

 

This has to do with ambiguous method exception when overriding a property with the new keyword:

Details: http://blogs.msdn.com/thottams/archive/2006/03/17/553376.aspx

 

Thanks,