[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.remoting

Windows services and remoting

Giox

10/27/2004 6:46:00 AM

Hello everybody, I have problem using Windows Services.
I want to host a server application on in a windows service and I'm
not able to do that. In effect when I try to start the service I
receive an error that says something like that: "The ServerCrypto
service on the local computer has been started and then stopped. Some
services stop automatically if there aren't operation to execute, for
example ........ " (I hope this is correct I tried to translate the
italian message that I received). I'm not an expert of windows
services (in effect up to now I used the IIs to host remote server but
now I cannot do that:-( ) and so I'm not able to understand where can
be my error... the thing that I don't understand is why I receive the
same error message when I try the code proposed by Ingo Rammer in his
book.... do you have some indication?


--
My Email is correct

Inviato da www.mynewsgate.net
2 Answers

Ken Kolda

10/27/2004 3:13:00 PM

0

This generally means that an exception occurred during the startup of your
service process and caused the process to terminate. A couple of things to
look out for:

1) In the Main() routine of your service class, you should have code that
look like:

System.ServiceProcess.ServiceBase[] ServicesToRun;
ServicesToRun = new System.ServiceProcess.ServiceBase[] { new
MyService() };
System.ServiceProcess.ServiceBase.Run(ServicesToRun);

where MyService is the name of your service class.

2) If you do any kind of initialization prior to the lines of code above or
within the constructor for MyService(), make sure you have a try/catch so
you can log any startup errors (e.g. to the event log). That way you'll be
able to see any exception that occurs during startup. You could also just
use a MessageBox by specify the MessageBoxOptions.ServiceNotification
option, e.g.

try
{
// Your initialization code
}
catch (Exception ex)
{
MessageBox.Show(null, ex.ToString(), "My Service", MessageBoxButtons.OK,
MessageBoxIcon.Error, MessageBoxDefaultButton.Button1,
MessageBoxOptions.ServiceNotification);
}

Using the ServiceNotification causes the message to go to the Application
Event Log if the service is not running in interactive mode.

Hope that helps -
Ken


"Giox" <gioparodi-forng@yahoo.it> wrote in message
news:200410270645405218@mynewsgate.net...
> Hello everybody, I have problem using Windows Services.
> I want to host a server application on in a windows service and I'm
> not able to do that. In effect when I try to start the service I
> receive an error that says something like that: "The ServerCrypto
> service on the local computer has been started and then stopped. Some
> services stop automatically if there aren't operation to execute, for
> example ........ " (I hope this is correct I tried to translate the
> italian message that I received). I'm not an expert of windows
> services (in effect up to now I used the IIs to host remote server but
> now I cannot do that:-( ) and so I'm not able to understand where can
> be my error... the thing that I don't understand is why I receive the
> same error message when I try the code proposed by Ingo Rammer in his
> book.... do you have some indication?
>
>
> --
> My Email is correct
>
> Inviato da www.mynewsgate.net


Giox

10/28/2004 7:23:00 AM

0

Thanks, there was a stupid error, I was trying to read a configuration
file in which I did an XML error :-(
Thks

Ken Kolda <ken.kolda@elliemae-nospamplease.com> ha scritto:

> This generally means that an exception occurred during the startup of
your
> service process and caused the process to terminate. A couple of things
to
> look out for:
>
> 1) In the Main() routine of your service class, you should have code
that
> look like:
>
> System.ServiceProcess.ServiceBase[] ServicesToRun;
> ServicesToRun = new System.ServiceProcess.ServiceBase[] { new
> MyService() };
> System.ServiceProcess.ServiceBase.Run(ServicesToRun);
>
> where MyService is the name of your service class.
>
> 2) If you do any kind of initialization prior to the lines of code
above or
> within the constructor for MyService(), make sure you have a try/catch
so
> you can log any startup errors (e.g. to the event log). That way you'll
be
> able to see any exception that occurs during startup. You could also
just
> use a MessageBox by specify the MessageBoxOptions.ServiceNotification
> option, e.g.
>
> try
> {
> // Your initialization code
> }
> catch (Exception ex)
> {
> MessageBox.Show(null, ex.ToString(), "My Service",
MessageBoxButtons.OK,
> MessageBoxIcon.Error, MessageBoxDefaultButton.Button1,
> MessageBoxOptions.ServiceNotification);
> }
>
> Using the ServiceNotification causes the message to go to the
Application
> Event Log if the service is not running in interactive mode.
>
> Hope that helps -
> Ken
>
>
> "Giox" <gioparodi-forng@yahoo.it> wrote in message
> news:200410270645405218@mynewsgate.net...
> > Hello everybody, I have problem using Windows Services.
> > I want to host a server application on in a windows service and I'm
> > not able to do that. In effect when I try to start the service I
> > receive an error that says something like that: "The ServerCrypto
> > service on the local computer has been started and then stopped. Some
> > services stop automatically if there aren't operation to execute, for
> > example ........ " (I hope this is correct I tried to translate the
> > italian message that I received). I'm not an expert of windows
> > services (in effect up to now I used the IIs to host remote server but
> > now I cannot do that:-( ) and so I'm not able to understand where can
> > be my error... the thing that I don't understand is why I receive the
> > same error message when I try the code proposed by Ingo Rammer in his
> > book.... do you have some indication?
> >
> >
> > --
> > My Email is correct
> >
> > Inviato da www.mynewsgate.net
>


--
My Email is correct

Inviato da www.mynewsgate.net