Ken Kolda
7/14/2004 10:41:00 PM
See Sunny''s example of an event wrapper -- this is probably the easiest way
to deal with this issue without exposing your client to the server. That
said, as Sunny suggests, if you''re going to have multiple clients listening
for these events, I would avoid using server-based events. Using your own
callback is more work but provides greater control over what happens when an
error occurs invoking the event handler for a disconnected client.
Ken
"Bob Rundle" <rundle@rundle.com> wrote in message
news:%2345LVGfaEHA.3692@TK2MSFTNGP09.phx.gbl...
> Ken,
>
> Indeed you are correct. I discovered that once I had the syntax correct,
I
> got a runtime serialization error indicating that server could not find
the
> client assembly.
>
> My next step was to implement an abstract class in the shared assembly
with
> a derived class in the client. No good. The server still wants the client
> assembly.
>
> Finally I implemented a concrete class in the shared assembly and this
> works!
>
> But the whole point is to execute some client specific code. So now I
need
> to set a client reference in this shared concrete class...
>
> Regards,
> Bob Rundle
>
> "Ken Kolda" <ken.kolda@elliemae-nospamplease.com> wrote in message
> news:OA8cO%23eaEHA.644@tk2msftngp13.phx.gbl...
> > The correct syntax is:
> >
> > platform.Workshops.OnChanged += new
> > OnChangedDelegate(((joaCollectionEvents)this).OnChanged);
> >
> > That said, if you''re going to use events & delegates, you should know
that
> > even though you''ve tried to hide your client implementation behind the
> > joaCollectionEvents interface, you''ll still have to have your client
> > assembly available on the server (and, in that case, there''s really no
> point
> > to using the joaCollectionEvents interface since you could pass a
delegate
> > for any instance method).
> >
> > If you want to achieve true separation of client and server, you''ll need
> to
> > implement your own callbacks and registration methods.
> >
> > Ken
> >
> >
> > "Bob Rundle" <rundle@rundle.com> wrote in message
> > news:O8$jwqeaEHA.644@tk2msftngp13.phx.gbl...
> > > Right...
> > >
> > > Thanks to a lot of help from this group, I''ve almost got my .NET
> remoting
> > > prototype put together..
> > >
> > > There is one final bit of foolishness...wiring the remote events.
> > >
> > > It almost works!
> > >
> > > I have a OnChanged() event that the server will raise whenever a
remote
> > > object is changed.
> > >
> > > Here is the way it is defined on the server
> > > public delegate void OnChangedDelegate(joaItem item);
> > >
> > > Here is the event...
> > >
> > > public class joaCollection : joaItem, IEnumerable
> > > {
> > > public event OnChangedDelegate OnChanged;
> > > //...
> > > };
> > >
> > > I tested the OnChanged event stand alone and it works great.
> > >
> > > Now I defined an interface that is compiled into a shared class
library
> to
> > > be shared by client and server...
> > >
> > > public interface joaCollectionEvents
> > >
> > > {
> > > void OnChanged(joaItem item);
> > > // ...
> > > }
> > >
> > > Now on the client, I have a form that I want to add change handling
> event
> > >
> > > public class joaPlatformForm : System.Windows.Forms.Form,
> > > joaCollectionEvents
> > > {
> > > //...
> > > private void LoadHandler(object sender, System.EventArgs e)
> > > {
> > > //...
> > > platform.Workshops.OnChanged += new OnChangedDelegate(OnChanged);
> > > }
> > >
> > > void joaCollectionEvents.OnChanged(joaItem item)
> > > {
> > > UpdateData();
> > > }
> > >
> > > }
> > >
> > > The problem: I can''t get this to compile. The compiler complains
that
> > > OnChanged does not exist in joaPlatformForm. I''ve tried various
syntax
> on
> > > the line containing the "+=" without success.
> > >
> > > What is the proper syntax?
> > >
> > > Regards,
> > > Bob Rundle
> > >
> > >
> > >
> > >
> > >
> > >
> >
> >
>
>