C# windows Service problems

B

badar.waqas

I have written a window service in C#. On windows XP it runs fine. I
checked it on my computer and some other computers in office. I am
able to install it on production system. But when i try to run this
service i receive following error:

"ERROR 1053: The service did not respond to the start or control
request in timely fashion"

I google on this error. Most of people are saying that Start method of
service should return as soon as possible. In my start method, i am
opening a file, making a socket and creating and starting a thread.
After this when i try to uninstall the service i got following error:

Exception occurred while initializing the installation:
System.BadImageFormatException: Could not load file or assembly
'file:///C:\game firewall\New Folder (4)\Firewall.exe' or one of its
dependencies. The module was expected to contain an assembly
manifest..

ANY BODY COULD TELL ME TO RESOLVE THAT PROBLEM?
 
P

Peter Bromberg [C# MVP]

You might want to consider spawning a background thread in your Start method
that does all this stuff. This allows the start method to not block on
anything that your business logic is doing. Have no idea why you would get a
bad image exception on uninstallation. Are you trying to do something with
the service executable?
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com
 
R

Robbe Morris - [MVP] C#

If you want a simplistic approach, you can create a timer on your class
that is disabled by default. In the OnStart of your service, you
instantiate
your business logic class and call some sort of Initialize method. That
method
would register the timer elapsed event would active the timer (perhaps wait
for 250 milliseconds).

This would permit your OnStart to return very quickly and then the timer
would trigger the execution of your main business logic method.

Nothing wrong at all with Peter's suggestion for background threads. I
mention this technique as an alternative for a less experienced developer.

--
Robbe Morris [Microsoft MVP - Visual C#]
AdvancedXL Server, Designer, and Data Analyzer
Convert cell ranges in Excel to rule driven web apps
without IT programmers.
Free download: http://www.equalssolved.com/default.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top