属性已更改 |来电会员姓名 |歧义匹配异常
PropertyChanged | CallerMemberName | AmbiguousMatchExcpetion
我在运行时遇到以下错误:AmbiguousMatchExcpetion
"Ambiguous Match found."
有人知道是什么原因吗?
Class
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 Message=Mehrdeutige Übereinstimmung gefunden.
Source=mscorlib StackTrace:
bei System.RuntimeType.GetPropertyImpl(String name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[]
types, ParameterModifier[] modifiers) InnerException:
问题是,HtUserGroupSetup
中的 Permissions
属性 隐藏了 Permissions
属性基类 (HtUserGroup
).
public new List<HtPermissionSetup> Permissions
在 HtUserGroupSetup
中重命名 Permissions
属性 解决了问题。
我在运行时遇到以下错误:AmbiguousMatchExcpetion
"Ambiguous Match found."
有人知道是什么原因吗?
Class
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 Message=Mehrdeutige Übereinstimmung gefunden.
Source=mscorlib StackTrace: bei System.RuntimeType.GetPropertyImpl(String name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers) InnerException:
问题是,HtUserGroupSetup
中的 Permissions
属性 隐藏了 Permissions
属性基类 (HtUserGroup
).
public new List<HtPermissionSetup> Permissions
在 HtUserGroupSetup
中重命名 Permissions
属性 解决了问题。