I have created a CSLA application containing a BusinessBase class as DesignationEdit.It has only 2 properties:Id(Pk),Description.Application runs successfully.It displays a list of Designation & adds a new Designation.
When editing an existing designation,i am getting an error as " Designation Id:Attempt by method System.Windows.CLRPropertyListener.set_Value(System.Object) to access method ProjectManagement.Library.DesignationEdit.set_Id(int 32) failed. "
The property declaration of Designation Id is:
public static readonly PropertyInfo<int> IdProperty = RegisterProperty<int>(c=>c.Id);
public int Id
{
get { return GetProperty(IdProperty);}
private set {LoadProperty(IdProperty,value);}
}
When i remove the private specifier from property setter,the error disappers.But i dont want to remove it. Then How to handle this error?
Hi,
A: if using Xaml - then make sure to make a one-way data binding or
B: Add Authz rule / override CanWriteProperty to return false for this property when object is "not New"
and make the property setter public. This will make the SetProperty throw an Exception that you are not allowed to Edit field.
You can then enhance UI further by using PropertyInfo and bind "Disabled" or "ReadOnly" to the PropertyInfo (when CanWriteProperty returns false).
Hi Jonny...
I made Mode=one way in the xaml for Id proeprty & it worked for me..
Thanks for your help..
Have a great time..
Copyright (c) Marimer LLC