473,569 Members | 2,870 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

About window service

Hello!

Below I have the two methods OnStart and Start that are relevant to my
question.
If I do net start TimeServerServi ce I will see something like Service
TimeServerServi ce starting .........
It wasn't possible to start the service TimeServerServi ce
The reason for this it that OnStart doesn't return becuse it will stuck in a
loop in the
Start metod.

When this happened I go back to VS2005 and changed the code in OnStart to
this code
using a Thread instead
this.isStopped = false;
Thread t = new Thread(new ThreadStart(thi s.Start));
t.Start();

but when I compile I get this error message
Could not copy temporary files to the output directory.
The file 'TimeService.ex e' cannot be copied to the run directory. Det går
inte att komma åt filen eftersom den
används av en annan process.
The file 'TimeService.pd b' cannot be copied to the run directory. Det går
inte att komma åt filen eftersom den
används av en annan process.

This text "Det går inte att komma åt filen eftersom den används av en annan
process" is in english something like
The file in not reachable because another process is using it.

I had to reboot before being able to compile my project.

When the Service OnStart doesn't return it seems to be a system process that
is holding it in some way according to the compile error.

How can I solve this problem without rebooting?
protected override void OnStart(string[] args)
{
isStopped = false;
Start();
}

public void Start()
{
this.listener.S tart();

Socket s;
Byte[] incomingBuffer;
Byte[] time;
int bytesRead;

while (!this.isStoppe d)
{
s = this.listener.A cceptSocket();
incomingBuffer = new Byte[100];
bytesRead = s.Receive(incom ingBuffer);

time = Encoding.ASCII. GetBytes(
System.DateTime .Now.ToString() .ToCharArray()) ;
s.Send(time);
}
this.listener.S top();
}

//Tony
Oct 29 '07 #1
2 1561

"TonyJ" <jo************ *****@telia.com wrote in message
news:ek******** ******@TK2MSFTN GP06.phx.gbl...

<snipped>
>
but when I compile I get this error message
Could not copy temporary files to the output directory.

When the Service OnStart doesn't return it seems to be a system process
that
is holding it in some way according to the compile error.

How can I solve this problem without rebooting?
The exe is still holding on to resources and access is being denied to the
exe file so that it can be replaced with a new exe.

You should use the .Net InstallUtil (for .Net NT services) to uninstall the
service. You should be able to compile then to create the exe. But
sometimes, you got to boot the machine to get rid of the lockout on the exe,
if it has horribly aborted/terminated.


Oct 29 '07 #2
Tony,
Try using code like this which will run your service as an EXE in debug
mode without installing, and when compiled in release mode, you can install
as a service:

// The main entry point for the process
static void Main()
{
#if (!DEBUG)
System.ServiceP rocess.ServiceB ase[] ServicesToRun;
ServicesToRun = new System.ServiceP rocess.ServiceB ase[] { new Service1() };
System.ServiceP rocess.ServiceB ase.Run(Service sToRun);
#else
// debug code: allows the process to run as a non-service
// will kick off the service start point, but never kill it
// shut down the debugger to exit
Service1 service = new Service1();
service.();
System.Threadin g.Thread.Sleep( System.Threadin g.Timeout.Infin ite);
#endif
}

-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com

"TonyJ" wrote:
Hello!

Below I have the two methods OnStart and Start that are relevant to my
question.
If I do net start TimeServerServi ce I will see something like Service
TimeServerServi ce starting .........
It wasn't possible to start the service TimeServerServi ce
The reason for this it that OnStart doesn't return becuse it will stuck in a
loop in the
Start metod.

When this happened I go back to VS2005 and changed the code in OnStart to
this code
using a Thread instead
this.isStopped = false;
Thread t = new Thread(new ThreadStart(thi s.Start));
t.Start();

but when I compile I get this error message
Could not copy temporary files to the output directory.
The file 'TimeService.ex e' cannot be copied to the run directory. Det går
inte att komma åt filen eftersom den
används av en annan process.
The file 'TimeService.pd b' cannot be copied to the run directory. Det går
inte att komma åt filen eftersom den
används av en annan process.

This text "Det går inte att komma åt filen eftersom den används av en annan
process" is in english something like
The file in not reachable because another process is using it.

I had to reboot before being able to compile my project.

When the Service OnStart doesn't return it seems to be a system process that
is holding it in some way according to the compile error.

How can I solve this problem without rebooting?
protected override void OnStart(string[] args)
{
isStopped = false;
Start();
}

public void Start()
{
this.listener.S tart();

Socket s;
Byte[] incomingBuffer;
Byte[] time;
int bytesRead;

while (!this.isStoppe d)
{
s = this.listener.A cceptSocket();
incomingBuffer = new Byte[100];
bytesRead = s.Receive(incom ingBuffer);

time = Encoding.ASCII. GetBytes(
System.DateTime .Now.ToString() .ToCharArray()) ;
s.Send(time);
}
this.listener.S top();
}

//Tony
Oct 29 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2480
by: Usman | last post by:
Hi I have a window service written in C#. I have another application that requires a lengthy process to be performed like taking backup. How can I make this lengthy process be performed by window service in such a manner that my application may invoke the process. Is there any way that I can call some method written in window service apart...
1
1239
by: Sam | last post by:
Hi All I'm assigned a task to create some kind of services to monitor new sales in database and send out emails and I'm thinking to use window service to do that. Does anyone know where I can find some good samples of window service that do similar things? Can a window service send an http request? Any help would be greatly appreciated ...
4
17432
by: drodrig | last post by:
Hi. I am trying to close/kill all processes that show visible windows on Windows XP. So far I've created a script that uses win32gui.EnumWindows to iterate through all windows, check for which windows are visible, then send a WM_CLOSE message to the window to request that it closes. Of course, not all apps want to close nicely. At this...
2
1052
by: Jaye | last post by:
I have facing a difficult problem about windows service I have created a windows Service and I have add some set/get method to return the value that caluate in background. And i have another window form application, in this, i would like to get back the value in the method that added in my windows service. Is it possible, if yes, how...
9
2474
by: =?Utf-8?B?UG90c2FuZw==?= | last post by:
Hi, I have a window service program created in c#. The window service program is installed and running. In the mean time, I have another c# application, I would like to know if there is a way to find out in this c# application where (the complete path)the window service program is running from. Can someone provide the sample code? ...
1
1287
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Hello Everyone, I have created a very simple window service. This window service in turn is calling a function that exist in a windows form. When I am trying to run this windows service. window service does not run and start throwing error message. Once I remove the windows form and put that same method in a class and call that class from...
7
8623
by: =?Utf-8?B?Vmlua2k=?= | last post by:
public void sendKeysTest() { Process myProcess = Process.Start(@"C:\winnt\system32\cmd.exe"); SetForegroundWindow(myProcess.Handle); if (myProcess.Responding) SendKeys.SendWait("{ENTER}"); else
0
1898
by: henkya | last post by:
Language Used: C# Project Typed: Setup Project (for .NET Window Service) Hi Bump into this issue and seriously have a hunch that this is a bug in the .NET setup project. These are the scenario: - I have an existing Window-Service application written in C#, and was build following the general deploying Window-Service guideline (the...
0
848
by: olanger | last post by:
Let me explain the scenerio, I have a window service that has timer and OnElapsed timer event I'm calling a method. This method process business logic and It's multi threaded. The problem...when the window service starts and you try to stop it by going to the window service and pressing stop, It won't. I'm getting a message "the service didn't...
2
1726
by: gray d newbie | last post by:
Greetings All, This is my first time creating a Window Service and I am having this error message when I try to start my window service (currently known as Service1). Below is my code for Window Service and also the line which I suspected is the caused of the problem. Protected Overrides Sub OnStart(ByVal args() As String) Dim i As...
0
7693
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7917
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7665
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6277
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2105
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
933
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.