467,161 Members | 974 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,161 developers. It's quick & easy.

Remoting - WIndows Service problem

Hi ,
Sorry i am posting this again as no one seems have taken notice of this
in the distributed appln forum

I have a remote server which works fine. The Client ans server work with
no problem.

However when i convert the server to a windows service i run into problems.
The service installs fine and starts fine too. It also seems to register the
channels and create the well know types.

However when i try to access the server using the client it throws an
exception
"Exception has been thrown by the target of an invocation." This is
precisely thrown when the proxy object on the client tries to access a
property or method from the remote server. The server itself does not throw
any errors.

Below is the server code for OnStart.

Please can someone give me any clues of what could be happening?

protected override void OnStart(string[] args)
{
// TODO: Add code here to start your service.
try
{

fs = new StreamWriter(new
System.IO.FileStream("C:\\temp\\mcTest.txt",FileMo de.Append ));

BinaryServerFormatterSinkProvider provider = new
BinaryServerFormatterSinkProvider();
provider.TypeFilterLevel = TypeFilterLevel.Full;

IDictionary props = new Hashtable();
props["port"] = 8085;
TcpChannel myChannel = new TcpChannel(props, null, provider);
fs.WriteLine("port");

//register channel
ChannelServices.RegisterChannel(myChannel);

fs.WriteLine("RegisterChannel");
//Register services
RemotingConfiguration.ApplicationName = "AServer";
RemotingConfiguration.Configure(System.AppDomain.C urrentDomain.BaseDirectory.ToString() + "AServer.exe.config");
RemotingConfiguration.RegisterWellKnownServiceType (
typeof(RemoteObject),
"RemoteObject",
WellKnownObjectMode.Singleton);

fs.Close();
}
catch(Exception err)
{
if (fs !=null)
{
fs.Close();
}

fs = new StreamWriter(new
System.IO.FileStream("C:\\temp\\mcTest.txt",FileMo de.Append));
fs.WriteLine(err.Message );
fs.Close();

}
finally
{
fs = new StreamWriter(new
System.IO.FileStream("C:\\temp\\mcTest.txt",FileMo de.Append));
fs.WriteLine("finally" );
fs.Close();
}


}

Was this post helpful to you?

Why should I rate a post?

Expand AllCollapse All
Manage Your Profile |Legal |Contact Us |MSDN Flash Newsletter
Aug 16 '06 #1
  • viewed: 1084
Share:
1 Reply
A Windows Service does not run in the same namespace.
Aug 16 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Linesh Gajera | last post: by
15 posts views Thread by anders@aleborg.se | last post: by
12 posts views Thread by Mural Kumar via .NET 247 | last post: by
5 posts views Thread by LGHummel | last post: by
2 posts views Thread by Stephajn Craig | last post: by
reply views Thread by Jason | last post: by
8 posts views Thread by nyhetsgrupper@gmail.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.