Remoting

I am mid way through writing a .Net Remoted object.  I have the server, the client and the object.  Everything is operating normally.  My only issue with this whole affair is that I need to keep the server running at all times.

All the samples do something like :

chan = new TcpChannel(8085);
ChannelServices.RegisterChannel(chan);
System.Type typ = typeof(AuthEngine.CreditCardEngine);
RemotingConfiguration.ApplicationName = "CreditCardAuthAuthorization";
RemotingConfiguration.RegisterWellKnownServiceType (typ, "Authorization", WellKnownObjectMode.SingleCall);
ReadLine ("Press return to end")

This seems really flaky.  As a temporary measure I put this code in a form and made the channel a member variable which would destroy (ie unregister) when the form is closed.  This still means I have a floating form on the screen.

Q) Has anybody done anything more elegant than this?
LVL 2
dhodgeAsked:
Who is Participating?
 
AvonWyssConnect With a Mentor Commented:
Why aren't you putting the server part into a windows service if you want it running all the time? Or, if it hat to be a forms application, you can lso just set up, store the reference in a static field, and forget the service...

Do this in the very first lines of Main() - therefore making sure that it stays running...
0
 
SijinCommented:
You could use a windows service. Use the new project wizard to select a windows service project and create a new windows service all the code is almost generated for you. Just move the above code to the OnStart() method of the service.

You may also need to add a installer to the project if you need to install the service, to do so you will have to goto design view of the service and click on the Add installer link.

Let me know if you face any problems.
0
 
smeggheadCommented:
It depends really. If, as you say, you are mid way through developing this component, then maybe it's best to leave it as a console application. This way you can write various informatative messages to the console window to aid you debugging and let you see what's going on.

But defintelely, when you complete the component, wrap it up in a windows service. (as the others say)

0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
dhodgeAuthor Commented:
Interesting, the thing I was trying to acheive with all this remoting stuff was an 'out of process exe'.  

Since there is no direct .Net equivalent I looked into Remoting because I didn't want the headache of maintaining a service.

Any more thoughts ?
0
 
smeggheadCommented:
Maintaining a service is very easy in .net - it shouldn't cause you too much of a headache.

Smg.
0
 
dhodgeAuthor Commented:
Does anybody think there is any advantages to remoting (supported by a service form the server) over a service doing the whole thing?  Probably the entire installation of this component(s) will be local machine anyway.
0
 
smeggheadCommented:
if you have a service doing the whole thing, you still need a mechanism to communicate with it.. and that will probably be remoting (unless you write your own)

0
 
smeggheadCommented:
can you explain your configuration, and why you want to use an out of process .exe equivalent.

It may be that .net has a different method of achieving your final goal, and you may be barking up the wrong tree.
0
 
dhodgeAuthor Commented:
We use a third party program that is mission critical (hate them words) it must store state at process level, we guess this because whenever we run it in IIS (on any isolation level) the whole system dies.  Unless we move it out of process.

The remoting has moved it out of process, but it comes with having to somehow keep the server running.

I believe the other option is a service, because this would also be out of process.
0
 
AvonWyssCommented:
THe proper way to deal with this is to use NLB (Network Load Balancing). This feature comes with Windows 2000 Advanced and Datancenter Server, as well as with all (!) .NET server editions (also Web Server).

NLB enabled you to have several machines listen on the same IP address and ports simultaneously. Depending on configuration, you can have the incoming requests distributed randomly on the machines (best load distribution, but may rise issues with statefulness), or have every source IP talk to one specific machine (sort of sateful per IP address), or always use the same machine until it fails (stateful, fallback).

Your service then runs normally on several machines in parallel, and you don't have to care about the failover yourself - and you can even use the load balancing to enhance performance when several machines are answering requests at the same time.
0
 
AvonWyssCommented:
Aren't you fully satisfied with the answer? You gave me a B grade, so there must be something you were not happy with - please let me know so that I can enhance the quality of my future answers.
0
 
dhodgeAuthor Commented:
I guess an A grade would have been an example of what code I would have had to put into the service.
0
 
AvonWyssCommented:
The same come you're using in the nnormal app... and since the code for the service is created automatically, I don't see what code you would have expected?
0
All Courses

From novice to tech pro — start learning today.