Remoting trouble

D

Derrick

Hello all;

I'm having a bit of trouble with .NET remoting. Here's my scenario:

I have a "remotable" type which is served by a Windows Service. I
have a WinForms app which consumes the remotable type. I'm using the
Observer pattern, so the client registers with the server, and the
server refreshes the client as appropriate (doing it this way because
the server polls a device over the serial port, and will update any
registered clients after the poll cycle is complete).

When I start the service, then load the WinForms app, everything works
just fine. However, if I exit the WinForms app, let the service
continue running and then start the WinForms app a second time, I get
the "Server refused connection" exception. If I restart the service,
everything works again.

I assume that there's some kind of remoting clean up I should be
doing, either as the Win app exits, or on the server side as the
Observer unregisters (which I do on dispose of the WinForm)? For what
it's worth, I'm doing all the remoting config programmatically.

Thanks for any help,

Derrick
 
D

DeveloperX

Hello all;

I'm having a bit of trouble with .NET remoting. Here's my scenario:

I have a "remotable" type which is served by a Windows Service. I
have a WinForms app which consumes the remotable type. I'm using the
Observer pattern, so the client registers with the server, and the
server refreshes the client as appropriate (doing it this way because
the server polls a device over the serial port, and will update any
registered clients after the poll cycle is complete).

When I start the service, then load the WinForms app, everything works
just fine. However, if I exit the WinForms app, let the service
continue running and then start the WinForms app a second time, I get
the "Server refused connection" exception. If I restart the service,
everything works again.

I assume that there's some kind of remoting clean up I should be
doing, either as the Win app exits, or on the server side as the
Observer unregisters (which I do on dispose of the WinForm)? For what
it's worth, I'm doing all the remoting config programmatically.

Thanks for any help,

Derrick

I'm not an expert, but I've never had to do anything clever to shut
down my remoting.
Is the error you get:

"No connection could be made because the target machine actively
refused it" ?

If so that means the socket is closed on the server
In my remoting primer which is a very simple forms based server and
client I get that error in the client when the server isn't running.

So you're not doing something silly in the service like relinquishing
the socket? Or for example do you register it on a seperate thread
that ends? Not sure if that would affect it. And are you sure the
service is still running, and not hung or just not reporting that it
shut down?

Where's your ChannelServices.RegisterChannel(new TcpChannel(50050));
or however you're creating your channel?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top