我在运行时遇到以下错误:AmbiguousMatchExcpetion
“找到了模糊匹配。”
有人知道是什么原因吗?
public class MyTrimmedClass : Control, INotifyPropertyChanged
{
public HtUserGroupSetup CurrentUserGroupSetup
{
get { return _CurrentUserGroupSetup; }
set
{
if (_CurrentUserGroupSetup != value)
{
_CurrentUserGroupSetup = value;
OnPropertyChanged();
}
}
}
private HtUserGroupSetup _CurrentUserGroupSetup;
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
public class HtUserGroupSetup : HtUserGroup
{
public new List<HtPermissionSetup> Permissions
{
get { return _Permissions; }
set
{
if (_Permissions != value)
{
_Permissions = value;
OnPropertyChanged("Permissions");
}
}
}
private List<HtPermissionSetup> _Permissions = new List<HtPermissionSetup>();
public HtUserGroupSetup(HtUserGroup userGroup)
{
Name = userGroup.Name;
Description = userGroup.Description;
}
}
public class HtUserGroup : HtBaseServiceData
{
private string _Name = "";
[DataMember]
public string Name
{
get { return _Name; }
set
{
if (_Name != value)
{
_Name = value;
OnPropertyChanged("Name");
}
}
}
private string _Description = "";
[DataMember]
public string Description
{
get { return _Description; }
set
{
if (_Description != value)
{
_Description = value;
OnPropertyChanged("Description");
}
}
}
private List<HtPermission> _Permissions = new List<HtPermission>();
[DataMember]
public List<HtPermission> Permissions
{
get { return _Permissions; }
set
{
if (_Permissions != value)
{
_Permissions = value;
OnPropertyChanged("Permissions");
}
}
}
}
public abstract class HtBaseServiceData : INotifyPropertyChanged
{
protected void OnPropertyChanged(string property)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property));
}
public event PropertyChangedEventHandler PropertyChanged;
}
System.Reflection.AmbiguousMatchException ist aufgetreten。
HResult = -2147475171消息=MehrdeutigeÜbereinstimmunggefunden。
Source = mscorlib StackTrace: bei System.RuntimeType.GetPropertyImpl(String name,BindingFlags bindingAttr,Binder binder,Type returnType,Type [] types,ParameterModifier [] modifiers)InnerException:
答案 0 :(得分:1)
问题是,Permissions
中的HtUserGroupSetup
属性隐藏 baseClass(Permissions
)的HtUserGroup
属性。
public new List<HtPermissionSetup> Permissions
重命名Permissions
中的HtUserGroupSetup
属性解决了问题。