Ran into this error today:
failed in property IsDeleted —> System.Reflection.AmbiguousMatchException: Ambiguous match found. at System.RuntimeType.GetPropertyImpl
I knew that we happened to have a property on our class called IsDeleted that shadowed a property in the CSLA base class, but I didn’t think it should be running into this problem.
After tracking down some reference info here http://msdn.microsoft.com/en-us/library/zy0d4103.aspx I found otu that the issue isn’t that we are shadowing, it’s that we are shadowing while at the same time changing the type.
The documentation seems to indicate that both situations should fail, but in my tests, the only time I got the exception was when my shadowing property had a different type. In this case, we were using a Nullable(of boolean) while the CSLA element was just a plain old Boolean.
I guess we are going to rename our property to make things easy on ourselves, but seeing as how this is codegenerated, it’s a little more of a pain than you might think. But, oh well.
Here is some code that produces the error. If you change the 2nd property type to a string it works ok.
imports Microsoft.VisualBasic
imports System
Imports System.Collections.Generic
public module MyModule
sub Main
dim target as new baseclass
dim p as system.Reflection.PropertyInfo = target.GetType().GetProperty("Prop")
wl( p.GetValue(target, nothing))
RL()
end sub
#region "Helper methods"
sub WL(text as object)
Console.WriteLine(text)
end sub
sub WL(text as object, paramarray args as object())
Console.WriteLine(text.ToString(), args)
end sub
sub RL()
Console.ReadLine()
end sub
sub Break()
System.Diagnostics.Debugger.Break()
end sub
#end region
end module
public class BaseBaseClass
public readonly property Prop as string
get
return "BaseBaseClass"
end get
end property
end class
public class BaseClass
inherits BaseBaseClass
public readonly property Prop as integer
get
return 123
end get
end property
end class