What Changed
We have changed the behavior of XPObjectSpace created by SecuredObjectSpaceProvider and the behavior of SecuredEFCoreObjectSpace created by SecuredEFCoreObjectSpaceProvider. Now, IObjectSpace.CommitChanges will throw the following exceptions on attempts to perform actions prohibited by security rules:
- XPObjectSpace - UserFriendlyObjectLayerSecurityException.
- SecuredEFCoreObjectSpace - UserFriendlyEFCoreSecurityException.
UserFriendlyObjectLayerSecurityException is an ObjectLayerSecurityException descendant and UserFriendlyEFCoreSecurityException is inherited from the Exception. Both exception types implement the IUserFriendlyException interface that is processed by XAF UI - a user-friendly error dialog is displayed instead of a fatal error.
Reasons for Change
These changes are required to correctly handle errors related to XAF's UI Actions prohibited by Action permissions.
Impact on Existing Apps
If your application has the code that checks for the exact exception type to handle exceptions raised when the IObjectSpace.CommitChanges method is called, your condition won't be met. Examples:
C#using DevExpress.Xpo.Exceptions;
//...
try {
// do something
objectSpace.CommitChanges();
}
catch(Exception e){
if(e.GetType() == typeof(ObjectLayerSecurityException)) {
// do something
}
}
Visual BasicImports DevExpress.Xpo.Exceptions
'...
Try
' do something
objectSpace.CommitChanges()
Catch e As Exception
If e.GetType() = GetType(ObjectLayerSecurityException) Then
' do something
End If
End Try
How to Update Existing Apps
Re-write your existing code as shown below:
C#try {
// do something
objectSpace.CommitChanges();
}
catch(ObjectLayerSecurityException e) {
// do something
}
Visual BasicTry
' do something
objectSpace.CommitChanges()
Catch e As ObjectLayerSecurityException
' do something
End Try