By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,564 Members | 804 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,564 IT Pros & Developers. It's quick & easy.

Remoting object - "Requested Service Not Found"

P: n/a
Hi All,

I have a Windows Service that runs well. The service hosts a remote object.
The purpose of the object is so that I can "peak" into the service to see
what it's doing. I wrote a small Windows Application that connects to the
remote object and prints out status information.
Everything works fine when I first start the service. However, after some
period, when I attempt to connect to the remote object, I get "Requested
Service not Found" when I try to bind to it.

I can confirm that the Service is still running, because it is doing what it
is supposed to be doing (processing logfiles) but the Remote Object isn't
working. The Remote Object is instantiated in the main thread for the
service, so it's not that the remote object is getting destroyed.

Some more troubleshooting shows that it isn't on the second connection
attempt that I cannot connect. I thought it might be the local object
destroying the remote object when the "client" app closes. This doesn't seem
to be the case.

The instance of the remote object is populated by the service with
information as it is running. So I'm fairly certain the the actual instance
of the object still exists, because if it was destroyed, then the service
would probably crash, which it doesn't.

Anyone have any ideas on what I'm doing wrong or not doing?

Here is the server side code that creates the object: (Object name is
"AllStatus")

HttpChannel channel = new
HttpChannel(Convert.ToInt32(ConfigurationSettings. AppSettings["StatusPort"])
);
ChannelServices.RegisterChannel(channel);
ObjRef refl = RemotingServices.Marshal(AllStatus,"objectluri");

Here is the client code that attempts to connect to it:

string RemoteConnection = "http://" + this.textBox1.Text + ":" +
this.textBox3.Text + "/objectluri";

RemotingConfiguration.RegisterWellKnownClientType( typeof(SessionLogger.Servi
ceStatus),RemoteConnection );
object1 = new SessionLogger.ServiceStatus();

To get the obvious questions out of the way, yes, I'm sure that the host and
port numbers are the same.

Thanks in Advance..

Steve



Nov 16 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Steve,

Is there a reason why you are not registering the type on the service
side? My guess is that you are marshaling a reference, and that the lease
is dying out. You should be configuring the type on the server to be
marshaled (using the static RegisterWellKnownServiceType method on the
RemotingConfiguration class).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Steve Lutz" <sl*********@comcast.net> wrote in message
news:Of**************@TK2MSFTNGP12.phx.gbl...
Hi All,

I have a Windows Service that runs well. The service hosts a remote object. The purpose of the object is so that I can "peak" into the service to see
what it's doing. I wrote a small Windows Application that connects to the
remote object and prints out status information.
Everything works fine when I first start the service. However, after some
period, when I attempt to connect to the remote object, I get "Requested
Service not Found" when I try to bind to it.

I can confirm that the Service is still running, because it is doing what it is supposed to be doing (processing logfiles) but the Remote Object isn't
working. The Remote Object is instantiated in the main thread for the
service, so it's not that the remote object is getting destroyed.

Some more troubleshooting shows that it isn't on the second connection
attempt that I cannot connect. I thought it might be the local object
destroying the remote object when the "client" app closes. This doesn't seem to be the case.

The instance of the remote object is populated by the service with
information as it is running. So I'm fairly certain the the actual instance of the object still exists, because if it was destroyed, then the service
would probably crash, which it doesn't.

Anyone have any ideas on what I'm doing wrong or not doing?

Here is the server side code that creates the object: (Object name is
"AllStatus")

HttpChannel channel = new
HttpChannel(Convert.ToInt32(ConfigurationSettings. AppSettings["StatusPort"]) );
ChannelServices.RegisterChannel(channel);
ObjRef refl = RemotingServices.Marshal(AllStatus,"objectluri");

Here is the client code that attempts to connect to it:

string RemoteConnection = "http://" + this.textBox1.Text + ":" +
this.textBox3.Text + "/objectluri";

RemotingConfiguration.RegisterWellKnownClientType( typeof(SessionLogger.Servi ceStatus),RemoteConnection );
object1 = new SessionLogger.ServiceStatus();

To get the obvious questions out of the way, yes, I'm sure that the host and port numbers are the same.

Thanks in Advance..

Steve



Nov 16 '05 #2

P: n/a
Are you instantiating the remoting object in Main() ??? That's probably not the right place to do it - try initialising your remoting layer in the OnStart() event

There's an article here that describes something similar to what you are doing
http://msdn.microsoft.com/library/de...et11272001.asp
Nov 16 '05 #3

P: n/a
Hi Nicholas,

I was able to figure out the problem, it WAS because the lease was dying. My
problem is that I needed the remote client to connect to the same instance
of the object, not a new one. I read that if I did a singleton, it would
only create one object of the class, but it seems that it was creating one
instance of the class for remote clients, and one for non-remote. This
wouldn't work, and this is the only way I could find to have a remote client
connect to the same instance of a local instantiated object.

I fixed it by overriding the default
MarshalByRefObject.InitializeLifetimeService to return null, which tells
Remoting that the lease should never expire.

Unless you know of a way to have a remote object connect to an exisiting
instance of a class that the server created, I think I'm going to stick with
this method.

Thanks

Steve

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP12.phx.gbl...
Steve,

Is there a reason why you are not registering the type on the service
side? My guess is that you are marshaling a reference, and that the lease
is dying out. You should be configuring the type on the server to be
marshaled (using the static RegisterWellKnownServiceType method on the
RemotingConfiguration class).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Steve Lutz" <sl*********@comcast.net> wrote in message
news:Of**************@TK2MSFTNGP12.phx.gbl...
Hi All,

I have a Windows Service that runs well. The service hosts a remote object.
The purpose of the object is so that I can "peak" into the service to see what it's doing. I wrote a small Windows Application that connects to the remote object and prints out status information.
Everything works fine when I first start the service. However, after some period, when I attempt to connect to the remote object, I get "Requested Service not Found" when I try to bind to it.

I can confirm that the Service is still running, because it is doing what it
is supposed to be doing (processing logfiles) but the Remote Object

isn't working. The Remote Object is instantiated in the main thread for the
service, so it's not that the remote object is getting destroyed.

Some more troubleshooting shows that it isn't on the second connection
attempt that I cannot connect. I thought it might be the local object
destroying the remote object when the "client" app closes. This doesn't

seem
to be the case.

The instance of the remote object is populated by the service with
information as it is running. So I'm fairly certain the the actual

instance
of the object still exists, because if it was destroyed, then the service would probably crash, which it doesn't.

Anyone have any ideas on what I'm doing wrong or not doing?

Here is the server side code that creates the object: (Object name is
"AllStatus")

HttpChannel channel = new

HttpChannel(Convert.ToInt32(ConfigurationSettings. AppSettings["StatusPort"])
);
ChannelServices.RegisterChannel(channel);
ObjRef refl = RemotingServices.Marshal(AllStatus,"objectluri");

Here is the client code that attempts to connect to it:

string RemoteConnection = "http://" + this.textBox1.Text + ":" +
this.textBox3.Text + "/objectluri";

RemotingConfiguration.RegisterWellKnownClientType( typeof(SessionLogger.Servi
ceStatus),RemoteConnection );
object1 = new SessionLogger.ServiceStatus();

To get the obvious questions out of the way, yes, I'm sure that the host

and
port numbers are the same.

Thanks in Advance..

Steve




Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.