Thanks for the feedback Stefan,
I think that if this exception gets thrown, it is because the UI developer didn't do their job. The UI should have use CanGetObject() to prevent the user from even trying to do the wrong thing, so the fact that the user was allowed to get here is a bug in the UI code.
But you are right - the literal string should be a resource. I'll add this to the to-do list.
Regarding the data portal - there are several virtual methods available. InvokeComplete is only called if the operation succceeds. There's another one (InvokeException maybe?) that is called when an exception occurs.
Oh, I’m sorry, I got it confused with the virtual methods…
You are right, these are static events on the DataPortal class itself.
To handle that event, you need to set up an event handler. You must
be careful where you do this, because hooking an event causes a reference from
the event source (DataPortal) to the handler. Since this is a static event,
that reference will never go away unless you unhook the event – which can
lead to memory leaks.
But to hook the event, you just use standard event handling
code. += in C# and AddHandler in VB.
Csla.DataPortal.InvokeComplete += MyHandler;
AddHandler Csla.DataPortal.InvokeComplete, AddressOf MyHandler
Rocky
From: stefan
[mailto:cslanet@lhotka.net]
Sent: Thursday, September 18, 2008 9:08 AM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] [Csla 3.5] Implications with the DataPortal
doing AuthorizationRules.CanXYZObject checks
But looking at the snippet I posted, it looks like
InvokeComplete is called in the case of an error occuring, with the
EventArgs containing the exception...
Stefan
Copyright (c) Marimer LLC