You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a recent problem on my CSLA object, that I can't figure out.
This app uses CSLA 4.11 (sic), and defines one of its properties what I believe is/was the 'standard way':
public Actions ActionPlan
{
get
{
if (!FieldManager.FieldExists(ActionPlanProperty))
{
LoadProperty(ActionPlanProperty, Actions.NewActions());
}
return GetProperty(ActionPlanProperty);
}
set
{
SetProperty(ActionPlanProperty, value);
}
}
`
With NewActions defined as: public static Actions NewActions() { return DataPortal.CreateChild<Actions>(); }
When I use the property setter for the first time, I get an exception from this CSLA code:
https://github.com/MarimerLLC/csla/blob/main/Source/Csla/Core/BusinessBase.cs
which used to be: protected void SetProperty<P>(PropertyInfo<P> propertyInfo, P newValue, Security.NoAccessBehavior noAccess) {
//...
//=> The type returned in fieldData is not the one I was expecting (FieldData) var fieldData = FieldManager.GetFieldData(propertyInfo); if (fieldData == null) {
//... } else { var fd = fieldData as FieldManager.IFieldData<P>; if (fd != null) oldValue = fd.Value; else
//=> Here I got an InvalidCastException : 'Unable to cast object of type 'System.Int32' to type 'MyNamespace.Actions'.' oldValue = (P)fieldData.Value;
I suspect the cause is around ((IPropertyInfo) propertyInfo).Index which (I think) incorrectly returns the index "1" . At this index, the FieldManager._fieldData contains another Property of my class which is of type PropertyInfo<int> instead of my PropertyInfo<Actions>; thus the InvalidCastException.
I'm trying to understand what causes the issue, but I don't know where/how to troubleshoot further.
I'm able to add breackpoints in the CSLA source code if I know where to look.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I have a recent problem on my CSLA object, that I can't figure out.
This app uses CSLA 4.11 (sic), and defines one of its properties what I believe is/was the 'standard way':
` public static readonly PropertyInfo ActionPlanProperty = RegisterProperty((c) => c.ActionPlan, "Action Plan");
`
With NewActions defined as:
public static Actions NewActions() { return DataPortal.CreateChild<Actions>(); }
When I use the property setter for the first time, I get an exception from this CSLA code:
https://github.com/MarimerLLC/csla/blob/main/Source/Csla/Core/BusinessBase.cs
which used to be:
protected void SetProperty<P>(PropertyInfo<P> propertyInfo, P newValue, Security.NoAccessBehavior noAccess) {
//...
//=> The type returned in fieldData is not the one I was expecting (FieldData)
var fieldData = FieldManager.GetFieldData(propertyInfo); if (fieldData == null) {
//...
} else { var fd = fieldData as FieldManager.IFieldData<P>; if (fd != null) oldValue = fd.Value; else
//=> Here I got an InvalidCastException : 'Unable to cast object of type 'System.Int32' to type 'MyNamespace.Actions'.'
oldValue = (P)fieldData.Value;
I suspect the cause is around
((IPropertyInfo) propertyInfo).Index
which (I think) incorrectly returns the index "1" . At this index, theFieldManager._fieldData
contains another Property of my class which is of typePropertyInfo<int>
instead of myPropertyInfo<Actions>
; thus theInvalidCastException
.I'm trying to understand what causes the issue, but I don't know where/how to troubleshoot further.
I'm able to add breackpoints in the CSLA source code if I know where to look.
Thanks for your guidance!
Beta Was this translation helpful? Give feedback.
All reactions