【大侠们,帮我看一个问题】我的错是注册服务后启动程序的时候“系统找不到指定的文件”。在线等,马上结贴

se7en 2011-03-18 11:29:10
我在注册服务以后 启动程序
ProPro方法里面的start()这里出错了。
我这是写的是物理路径。做测试的。、

报的错为:系统找不到指定的文件。
这是为什么呢??帮我看看。


/// <summary>
/// 注册服务
/// </summary>
/// <param name="strServiceName"></param>
/// <param name="strServiceInstallPath"></param>
public void Register(string servicesname, string strServiceInstallPath)
{
IDictionary mySavedState = new Hashtable();
try
{
System.ServiceProcess.ServiceController service = new System.ServiceProcess.ServiceController(servicesname);
//服务已经存在则卸载
if (ServiceIsExisted(servicesname))
{
UnInstallService(servicesname, strCurrPath);
}
service.Refresh();
//注册服务
AssemblyInstaller myAssemblyInstaller = new AssemblyInstaller();

mySavedState.Clear();
//myAssemblyInstaller.Path = strCurrPath;
myAssemblyInstaller.Path = "WSGPSServices.exe";
myAssemblyInstaller.UseNewContext = true;
myAssemblyInstaller.Install(mySavedState);
myAssemblyInstaller.Commit(mySavedState);
myAssemblyInstaller.Dispose();

service.Start();
ProPro();
}
catch (Exception ex)
{
throw new Exception("注册服务时出错:" + ex.Message);
}
}

/// <summary>
/// 启动服务程序
/// </summary>
public void ProPro()
{ System.Diagnostics.Process pro = new Process();
pro.StartInfo.FileName = @"D:\study\NewGPS\WSGPSGateway\WSGPSServices\bin\Release\WSGPSGateway.exe";
//pro.StartInfo.WorkingDirectory = "'D:'+'\'study'+'\'NewGPS'+'\'WSGPSGateway'+'\'WSGPSServices'+'\'bin'+'\'Release'";
//pro.StartInfo.Arguments = "D:\\study\\NewGPS\\WSGPSGateway\\WSGPSServices\\bin\\Release";
pro.StartInfo.CreateNoWindow = true;
try
{
pro.Start();
}
catch (Exception ex)
{
throw ex;
}
}
...全文
138 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ycproc 2011-03-22
  • 打赏
  • 举报
回复
找不到指定路径

。。。
se7en 2011-03-18
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 jijunwu 的回复:]
//myAssemblyInstaller.Path = strCurrPath;
myAssemblyInstaller.Path = "WSGPSServices.exe"; myAssemblyInstaller.UseNewContext = true;
myAssemblyInstaller.Install(mySavedState);
myAssemblyInstal……
[/Quote]

我的服务可以注册成功,这一步已经可以跳过 。but我是在下面程序启动的时候报的错 ,你能帮我分析一下是什么原因么?
  • 打赏
  • 举报
回复
//myAssemblyInstaller.Path = strCurrPath;
myAssemblyInstaller.Path = "WSGPSServices.exe"; myAssemblyInstaller.UseNewContext = true;
myAssemblyInstaller.Install(mySavedState);
myAssemblyInstaller.Commit(mySavedState);
myAssemblyInstaller.Dispose();

这里也修改为物理路径 试试

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧