Key: AR-163
URL: http://support.castleproject.org//browse/AR-163
Project: ActiveRecord
Issue Type: Bug
Affects Versions: RC 2
Environment: Castle build from build server,
.Net 2.0,
WinForms
FireBird 2
NHibernate.Generics
Reporter: Darius Damalakas
Priority: Critical
After enabling lazy on class,
WARN (e:\Projects\EMC\trunk\EMC.Properties\ReflectionPropertyAccess.cs:115) - Failed on type
CProxyTypeEMC_BLL_ModelGroupModel_NHibernate_ProxyINHibernateProxy1. Requested path SearchCodeProperty
System.Reflection.AmbiguousMatchException: Ambiguous match found.
at System.RuntimeType.GetPropertyImpl(String name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers)
at System.Type.GetProperty(String name)
The problem occurs when getting the class indirectly.
I.e. when loading ActiveRecordMediator<Group>.FindAll() returned Group classes are initialized ok, but
if I load students = ActiveRecorcdMediator<Student>.FindAll() and access the group via a property like (
students[0].GroupStudent[0].Group ) then I get the exception
This Issue might be related to http://support.castleproject.org/browse/MR-208
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://support.castleproject.org//secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
Is this DP 1 or DP 2?
> Ambiguous match exception
> -------------------------
>
> Key: AR-163
> URL: http://support.castleproject.org//browse/AR-163
> Project: ActiveRecord
> Issue Type: Bug
> Affects Versions: RC 2
> Environment: Castle build from build server,
> .Net 2.0,
> WinForms
> FireBird 2
> NHibernate.Generics
> Reporter: Darius Damalakas
> Assigned To: hamilton verissimo
we use DP 1
> Ambiguous match exception
> -------------------------
>
> Key: AR-163
> URL: http://support.castleproject.org//browse/AR-163
> Project: ActiveRecord
> Issue Type: Bug
> Affects Versions: RC 2
> Environment: Castle build from build server,
> .Net 2.0,
> WinForms
> FireBird 2
> NHibernate.Generics
> Reporter: Darius Damalakas
> Assigned To: hamilton verissimo
Please post the the ReflectionPropertyAccess and student/group code.
> Ambiguous match exception
> -------------------------
>
> Key: AR-163
> URL: http://support.castleproject.org//browse/AR-163
> Project: ActiveRecord
> Issue Type: Bug
> Affects Versions: RC 2
> Environment: Castle build from build server,
> .Net 2.0,
> WinForms
> FireBird 2
> NHibernate.Generics
> Reporter: Darius Damalakas
> Assigned To: hamilton verissimo
Similar error registered here:
: http://forum.castleproject.org/viewtopic.php?t=2006&highlight=dynamic+proxy
: http://forum.castleproject.org/viewtopic.php?t=1931&highlight=ambiguous
Proposes a simple solution to use BindingFlags.DeclaredOnly
: http://forum.castleproject.org/viewtopic.php?t=1637&highlight=ambiguous
hammet proposes to try use DP 2
:http://forum.castleproject.org/viewtopic.php?t=1268&highlight=ambiguous
same problem, but no important info provided
:http://forum.castleproject.org/viewtopic.php?t=574&highlight=ambiguous
same problem, but no info
:http://forum.castleproject.org/viewtopic.php?t=404&highlight=ambiguous
It seems that the only thing i can do is to test using DP 2, but this will be done only after weekend.
BTW - correct me if i'm wrong - to test with DP 2 I will have to rebuild NHibernate, after i change all references from DP 1 to DP 2. And castle build server does not build ActiveRecord with DP 2.
> Ambiguous match exception
> -------------------------
>
> Key: AR-163
> URL: http://support.castleproject.org//browse/AR-163
> Project: ActiveRecord
> Issue Type: Bug
> Affects Versions: RC 2
> Environment: Castle build from build server,
> .Net 2.0,
> WinForms
> FireBird 2
> NHibernate.Generics
> Reporter: Darius Damalakas
> Assigned To: hamilton verissimo
> at System.RuntimeType.GetPropertyImpl (String name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers)
I moved to DP2, the problem still persists.
@Ayende,
ReflectionPropertyAccess only wraps the call to GetProperty(...) with try catch block, and iterates through all properties until it find the one needed. (see code at the end of comment)
I have attached a project, witch contains all the model classes, and one test case, which throws AmbiguousMatchException. The demo uses DP2 and SQLite.
Attached files contains all necessary libraries, it should be possible to reproduce the bug.
====================
At the moment i can avoid the problem by accessing all properties with simple foreach loop like this:
PropertyInfo pi = null;
try
{
// Try get the needed property
pi = currentType.GetProperty(propertyName);
}
catch (AmbiguousMatchException )
{
// if we get exception, loop through all properties
PropertyInfo[] pis = currentType.GetProperties();
foreach (PropertyInfo propertyInfo in pis)
{
// and choose the property, which we need
if (propertyInfo.Name.Equals(propertyName))
{
pi = propertyInfo;
break;
}
}
}
> Ambiguous match exception
> -------------------------
>
> Key: AR-163
> URL: http://support.castleproject.org//browse/AR-163
> Project: ActiveRecord
> Issue Type: Bug
> Affects Versions: RC 2
> Environment: Castle build from build server,
> .Net 2.0,
> WinForms
> FireBird 2
> NHibernate.Generics
> Reporter: Darius Damalakas
> Assigned To: hamilton verissimo
> Priority: Critical
> Attachments: ActiveRecordLazy.zip
Darius Damalakas updated AR-163:
--------------------------------
Attachment: ActiveRecordLazy.zip
Conrtains a test case, which throws AmbiguousMatchException
> Ambiguous match exception
> -------------------------
>
> Key: AR-163
> URL: http://support.castleproject.org//browse/AR-163
> Project: ActiveRecord
> Issue Type: Bug
> Affects Versions: RC 2
> Environment: Castle build from build server,
> .Net 2.0,
> WinForms
> FireBird 2
> NHibernate.Generics
> Reporter: Darius Damalakas
> Assigned To: hamilton verissimo
> Priority: Critical
> Attachments: ActiveRecordLazy.zip
>
>
hamilton verissimo resolved AR-163.
-----------------------------------
Resolution: Won't Fix
This is a bug confirmed by Microsoft on SRE. I dont expect a fix in a near future.
> Ambiguous match exception
> -------------------------
>
> Key: AR-163
> URL: http://support.castleproject.org//browse/AR-163
> Project: ActiveRecord
> Issue Type: Bug
> Affects Versions: RC 2
> Environment: Castle build from build server,
> .Net 2.0,
> WinForms
> FireBird 2
> NHibernate.Generics
> Reporter: Darius Damalakas
> Assigned To: hamilton verissimo
> Priority: Critical
> Attachments: ActiveRecordLazy.zip
>
>