I would like to pay your attention to a couple of Support Center tickets on the subject: one and two.
It is important to remember that when you use SecuredObjectSpaceProvider (see Client-Side Security - Integrated Mode ) or configured a dedicated application server (as per Middle Tier Security - .NET Remoting Service), then you cannot write the code like this:
Session session = ((XPObjectSpace)View.ObjectSpace).Session;
UnitOfWork uow = new UnitOfWork(session.DataLayer);
I recommend you use the View.ObjectSpace object and its methods to query and manipulate your data, if possible. If, for some reason, you cannot follow this recommended approach, use the Session.ObjectLayer property instead of the Session.DataLayer one. BTW, you can check these two properties to execute your business logic on the server or on the client only: protected override void OnSaving() { Since we touched OnSaving here, I would also remind you that it can be executed several times in a general case (as per XPO Best Practices), so it is probably not the best place for your logic at all, unless you are ready to introduce additional checks here.
This is because it will always work correctly regardless of whether you are using a middle-tier server or not.
base.OnSaving();
if ((Session.DataLayer != null && Session.ObjectLayer == null) || (Session.DataLayer != null && Session.ObjectLayer != null))
//Execute some business logic on the server side (only once).
}
}