If I outcomment the last four lines the service will start.
If I in-comment the line
"int recv = sock.ReceiveFrom(data, ref ep);"
the service will fail starting with error code 3534 (the service
reported no errors). Neither are errors written to the event log.
If I run the same code from a console application, everything works
fine.
The code:
protected override void OnStart(string[] args)
{
IPEndPoint iep = new IPEndPoint(IPAddress.Any, 9050);
sock.Bind(iep);
EndPoint ep = (EndPoint)iep;
byte[] data = new byte[1024];
int recv = sock.ReceiveFrom(data, ref ep);
string stringData = Encoding.ASCII.GetString(data, 0,
recv);
data = new byte[1024];
}
Any ideas why that particular line prevents service from starting?
Regards
Morten Snedker
"Snedker" <Morten....@gmail.com> wrote in message
news:91969b26-2164-49ef...@d32g2000yqh.googlegroups.com...
> Hi folks,
>
> If I outcomment the last four lines the service will start.
>
> If I in-comment the line
> "int recv = sock.ReceiveFrom(data, ref ep);"
> the service will fail starting with error code 3534 (the service
> reported no errors). Neither are errors written to the event log.
>
>
> Any ideas why that particular line prevents service from starting?
Yeah, you aren't allowed to use blocking calls from the main thread of a
service, it has to return to the Service Control Manager.
>
> Regards
> Morten Snedker
"Snedker" <Morten....@gmail.com> wrote in message
news:91969b26-2164-49ef...@d32g2000yqh.googlegroups.com...
Yup - that was it. Thanks for your help!
Regards /Snedker