Windows服务并不适合所有人。 [英] windows service not working for everyone.

查看:60
本文介绍了Windows服务并不适合所有人。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我之前已经发过这个问题了。我有一个解决方法,但似乎并不合理。


我开发了一个Windows服务并将其安装在我们的服务器中。办公室里的每个人都可以访问服务器中的文件夹。任何人都可以将文件放在该共享文件夹中,服务必须将其取出。但它不适合所有人。它只是为一些用户选择。而奇怪的是它为其余的用户提供了接受但也是偶然的。


我没有得到如何让它一致地工作。关于这个问题的任何想法。


是否必须在管理员帐户下工作。如果是这样我应该怎么做。


请帮忙!

Ayush

Hi I have already posted this question before.I got a work around but doesn''t seem reasonable.

I developed a windows service and I installed it in our server.everybody in the office has access to a folder in the server.anybody can put a file in that shared folder and the service has to pick it up. but it does not pickup for everyone. it just picks up for some users. and the strange thing is it pickes up for rest of the users also but ocassionally.

Iam not getting how to make it work consistantly. any ideas on this issue.

does it have to work under admin account. if so what should i do for that.

please help!
Ayush

推荐答案



现在另一个问题我的服务是在网络服务帐户下运行的。如果我在本地系统帐户下运行它会有什么不同。我只是访问服务器上的本地驱动器没有远程或网络驱动器被访问所以本地系统帐户是否足以完成这项工作?


如果有人能告诉我有什么区别在这两个帐户之间它将是一个很大的帮助。

Ayush
Hi
also another question right now I have my service running under network service account. what difference will it make if I run it under local system account. I am just accessing local drives on the server no remote or network drives are being accessed so is the local system account enough to do the job?

If anyone can tell me what is the difference between the two accounts it''ll be a great help.
Ayush


"我开发了一个Windows服务,我将它安装在我们的服务器中。每个人都在办公室可以访问服务器中的文件夹。任何人都可以将文件放在该共享文件夹中,服务必须将其取出。但它不适合所有人。它只是为一些用户选择。而奇怪的是它为其余的用户提供了接受,但也是偶然的。

"

我没有得到如何让它一直工作。关于这个问题的任何想法。



您可以发布示例代码吗?您还在使用FileWatcher吗?你得到了什么样的错误(如果你得到的话)或例外情况? Plz发布更多信息和示例代码...
"I developed a windows service and I installed it in our server.everybody in the office has access to a folder in the server.anybody can put a file in that shared folder and the service has to pick it up. but it does not pickup for everyone. it just picks up for some users. and the strange thing is it pickes up for rest of the users also but ocassionally."
"
Iam not getting how to make it work consistantly. any ideas on this issue. "


Can you post a sample code... also are you using FileWatcher? What kinds of error, (in case you are getting) or exceptions are you gettin? Plz post more info and sample code...


感谢您的快速回复。


是的我正在使用filewatcher。这项服务对我来说很好(因为我把它安装在服务器上,我觉得它会对我有用)。


没有错误,服务只是意外地终止了一些尝试将文件放在该文件夹中的用户。作为恢复操作,我使服务重新启动。当同一个用户试图将文件放回其工作的文件夹中时。我不知道为什么它第一次停止。


代码:(文字)


1.公共服务1()

2. {

3.尝试

4. {

5. _timer = new Timer(6000);

6. InitializeComponent();

7.}

8. catch(Exception ex)

9. {

10. System.IO.StreamWriter tw = new System.IO.StreamWriter(" C:\\gggg\\jjjj \\error.txt",true);

11. tw.Write(ex);

12. tw.Close();

13.}

14 。



15. protected override void OnStart(string [] args)

16. {

17.尝试

18. {

19. _timer.Start();


20 .FileWatch.Path = ConfigurationSettings.AppSe ttings [" WatchPath"];

21. FileWatch.Created + = new FileSystemEventHandler(FileWatch_Created);


22.}

23. catch(exception ex)

{

24. System.IO.StreamWriter tw = new System.IO.StreamWriter(" C:\\ gggg\\jjjj\\error.txt" ,true);

25. tw.Write(ex);

26. tw.Close();

27.}

28.}



29.private void FileWatch_Created(对象发件人,

30.系统。 IO.FileSystemEventArgs e)

31. {

32. string [] filedata = File.ReadAllLines(e.FullPath);

33。 int maxlins = filedata.Length;


34. for(int i = 0; i< maxlins; i ++)

35. {

36. TranslateForm form = new TranslateForm();

37. form.newproperty(filedata,e);


38.}


39.}


希望这提供信息。如果我必须回答任何问题请告诉我
Thanks for the quick reply.

yes I am using filewatcher. and the service works fine for me(Since I installed it on the server,I am asuming it''ll work for me).

there is no error,service just termiates unexpectedly for some users who try to put a file in that folder. as a recovery action i made the service to restart. when the same user tries to put the file back in the folder it works. i dont know why it stops the first time.

Code:(text)

1. public Service1()
2. {
3. try
4. {
5. _timer = new Timer(6000);
6. InitializeComponent();
7. }
8. catch (Exception ex)
9. {
10. System.IO.StreamWriter tw = new System.IO.StreamWriter("C:\\gggg\\jjjj\\error.txt" , true);
11. tw.Write(ex);
12. tw.Close();
13. }
14. }




15. protected override void OnStart(string[] args)
16. {
17. try
18. {
19. _timer.Start();

20. FileWatch.Path = ConfigurationSettings.AppSettings["WatchPath"];
21. FileWatch.Created += new FileSystemEventHandler(FileWatch_Created);

22. }
23. catch(Exception ex)
{
24. System.IO.StreamWriter tw = new System.IO.StreamWriter("C:\\gggg\\jjjj\\error.txt" , true);
25. tw.Write(ex);
26. tw.Close();
27. }
28. }



29.private void FileWatch_Created(object sender,
30. System.IO.FileSystemEventArgs e)
31. {
32. string[] filedata = File.ReadAllLines(e.FullPath);
33. int maxlins = filedata.Length;

34. for (int i = 0; i < maxlins; i++)
35. {
36. TranslateForm form = new TranslateForm();
37. form.newproperty(filedata, e);

38. }

39. }

hope this provides the information.do let me know if i have to answer any questions


这篇关于Windows服务并不适合所有人。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆