Windows服务无法正常工作 [英] Windows Service is not Working
问题描述
我在C#中做了一个Windows服务在Visual Studio 2008年。服务里面我写了只有一行code
I had made a windows service in visual studio 2008 in C#. inside the service i had written only single line code
try
{
System.Diagnostics.Process.Start(@"E:\Users\Sk\Desktop\category.txt");
}
catch { }
然后我加入该项目的安装和放大器;改变将ServiceProcessInstaller1帐户属性作为本地系统也改变了serviceInstaller1开始type属性为自动。 然后我建立project.it成功。从那以后,我添加另一个项目,该项目是建立project.i又增加了重点项目输出和我已经添加了自定义操作为从DemoWindowsService主输出(活动),然后建setup.setup是构建successfully.then我安装设置和放大器;然后去服务启动service.service说正常,但它并没有执行任务。 我测试过的路径是正确的&放大器;此外,我试图做
then i add the project installer & change the serviceProcessInstaller1 Account property as local system Also change the serviceInstaller1 start type property as Automatic. then i build the project.it was successful. after that i add another project that was setup project.i had added primary project output & i had added the custom action as "Primary output from DemoWindowsService (Active)".then built the setup.setup was build successfully.then i install the setup & then went to services start the service.service stated properly but it was not performing the task. i had checked the path is correct & also i tried to do
System.Diagnostics.Process.Start(@E:\ WINDOWS \ SYSTEM32 \ NOTEPAD.EXE)
,但仍然导致被same.i尝试了很多,但不得到了答案。
System.Diagnostics.Process.Start(@"E:\Windows\system32\notepad.exe")
but still result is same.i tried a lot but not getting the answer.
推荐答案
如果它不工作,那么也许这是因为一个异常被抛出。但是,因为你隐藏你的try / catch块所有的异常,你永远不知道什么是错的。
If it's not working, then maybe it's because an exception was thrown. However, since you're hiding all exceptions with your try/catch block, you'll never know what's wrong.
摆脱try / catch块,并看看有没有什么帮助您了解什么是错的。
Get rid of the try/catch block, and see if that helps you learn what's wrong.
这篇关于Windows服务无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!