Subject: C# Windows Service Issue
Prev Next
You are not authorized to post a reply.

AuthorMessages
Bob EUser is Offline
New Poster
New Poster
Posts:3

01/07/2010 3:18 PM  

I created an C# Windows Form Application (Recorder) that records into an mp3 file.  All the dlls and “Lame.exe” are in the folder with the Recorder exe.  I run Recorder successfully from both the command line and a shortcut.

 

I also created a C# Windows Service (Monitor) that monitors Recorder to make sure that it is running all the time.  If Recorder is not running, Monitor restarts it.  Monitor successfully starts Recorder and everything is working except for the reference to “Lame.exe”.  I don’t get any sound when Recorder is started from Monitor.

 

Do you know how it might be different to run Recorder from a shortcut and a Windows Service calling it? 

 

Or is there another way to reference “Lame.exe” for a Windows Service?

 

Any help would be much appreciated.

 

Thanks,

Bob E

Algona, IA

Mitchel SellersUser is Offline
Site Admin/Owner
Guru
Guru
Posts:6089

01/12/2010 10:24 AM  
Bob,

Sorry for the delayed reply, I was on vacation!

How are you starting "Recorder" from the windows service? What path are you referencing?

The only real difference is, that "Monitor" could be running under a different user security context, such as LocalService or similar. If that account doesn't have permissions on the "Monitor" folder, it will not be able to reference lame.exe correctly.

-Mitchel Sellers
Microsoft C# MVP, MCITP
Director of Development
IowaComputerGurus Inc.

View Mitchel Sellers's profile on LinkedIn

For shared hosting I recommend PowerDNN

This site is hosted on a Dedicated Server from PowerDNN.com

To get Guaranteed DNN Support check out our affordable DNN Technical Support Programs
Bob EUser is Offline
New Poster
New Poster
Posts:3

01/12/2010 2:34 PM  

(Question) How are you starting "Recorder" from the windows service?

(Answer)

public string AppPath = "C:\\APPS\\DARAudit\\DARAuditV5.exe";
public string AppDirectory = "C:\\APPS\\DARAudit";
//Create process
APPProc = new Process();
APPProc.StartInfo.FileName = AppPath;
APPProc.StartInfo.WorkingDirectory = AppDirectory;
APPProc.EnableRaisingEvents = true;
APPProc.Exited += new EventHandler(APPProc_Exited);
APPProc.ErrorDataReceived += new DataReceivedEventHandler(APPProc_ErrorDataReceived);
APPProc.Start();

(Question)
What path are you referencing?

(Answer)
"C:\\APPS\\DARAudit\\DARAuditV5.exe"

 

The only real difference is, that "Monitor" could be running under a different user security context, such as LocalService or similar. If that account doesn't have permissions on the "Monitor" folder, it will not be able to reference lame.exe correctly.

(Answer)

I don't think that permissions is the problem.  The "Monitor" Service is running on a standalone computer that is not part of any domain.  I also am using the ServiceInstaller in Visual Studio to install the service.  The account property of the ServiceInstaller is set to LocalSystem.  Please explain this further if you think that is still the problem.

 

I have all the necessary dll's and "Lame.exe" in the C:\APPS\DARAudit directory where the Recorder exe also resides.  The Recorder App runs fine (Form is OK, other dll is working) except that it is still not referencing the "Lame.exe".  Therefore no encoding is working.  Any other ideas on how to reference the "Lame.exe"?

 

Please help.

Thanks,

Bob E

Mitchel SellersUser is Offline
Site Admin/Owner
Guru
Guru
Posts:6089

01/12/2010 2:57 PM  
Bob,

Based on what you are saying, make sure that LocalSystem has access to this folder. C:\\APPS\\DARAudit\\

Since that is the context that is being used to start the recorder from the service.

-Mitchel Sellers
Microsoft C# MVP, MCITP
Director of Development
IowaComputerGurus Inc.

View Mitchel Sellers's profile on LinkedIn

For shared hosting I recommend PowerDNN

This site is hosted on a Dedicated Server from PowerDNN.com

To get Guaranteed DNN Support check out our affordable DNN Technical Support Programs
Bob EUser is Offline
New Poster
New Poster
Posts:3

01/12/2010 3:12 PM  

Mitchel,

 

How do I make sure that LocalSystem has access to this folder? 

 

The available options for the ServiceAccount are:

1)  LocalSystem - An account, used by the service control manager, that has extensive privileges on the local computer and acts as the computer on the network.

2)  LocalService - An account that acts as a non-privileged user on the local computer, and presents anonymous credentials to any remote server.

3)  NetworkService - An account that provides extensive local privileges, and presents the computer's credentials to any remote server.

4)  User - An account defined by a specific user on the network. Specifying User for the Service ProcessInstaller Account [script removed] member causes the system to prompt for a valid user name and password when the service is installed, unless you set values for both the UserName and Password properties of your ServiceProcessInstaller instance.

 

The Local System option seems to be the option with the most access.   Is there another place or setting to change?

 

Thanks,

Bob E

Mitchel SellersUser is Offline
Site Admin/Owner
Guru
Guru
Posts:6089

01/12/2010 3:31 PM  
Right click on the folder, and select properties.

Go to sharing/security, add the user with full control to that directory.

-Mitchel Sellers
Microsoft C# MVP, MCITP
Director of Development
IowaComputerGurus Inc.

View Mitchel Sellers's profile on LinkedIn

For shared hosting I recommend PowerDNN

This site is hosted on a Dedicated Server from PowerDNN.com

To get Guaranteed DNN Support check out our affordable DNN Technical Support Programs
chrisadamUser is Offline
New Poster
New Poster
Posts:2

09/08/2010 6:12 AM  

 

I have c# windows service, which I am developing in visual studio 2008.

I have noticed that, when I start the service, the current culture info does not match the regional settings on my coputer.

When I am starting c# windows application, it uses the culture info according to my regional settings.

Why is it so ? why the windows service uses "en-US" , instead of using the correct cultureinfo according to my regional settings ?

thanks

 

Mitchel SellersUser is Offline
Site Admin/Owner
Guru
Guru
Posts:6089

09/08/2010 6:15 AM  
Chris,

THis is simple, the user context that the service is running under doesn't have a culture set more than likely. If you had it run as your account, you would see the proper culture.

-Mitchel Sellers
Microsoft C# MVP, MCITP
Director of Development
IowaComputerGurus Inc.

View Mitchel Sellers's profile on LinkedIn

For shared hosting I recommend PowerDNN

This site is hosted on a Dedicated Server from PowerDNN.com

To get Guaranteed DNN Support check out our affordable DNN Technical Support Programs
You are not authorized to post a reply.
Forums >Development Discussion >.NET Development > C# Windows Service Issue



ActiveForums 3.7