【已解决】Windows Service 问题System.IO.FileNotFoundException: 未能加载文件或程序集“file:///”或它 的某一个依赖项。系统找不到指定的文件。。

bat文件 内容为

cd C:\Windows\Microsoft.NET\Framework\v4.0.30319\
InstallUtil.exe  
InstallUtil F:\Windows Services\WindowsServiceTest\WindowsServiceTest_1_0_0_0\WindowsServiceTest.exe
Net Start Service1
pause

其中C:\Windows\Microsoft.NET\Framework\v4.0.30319\为installutil的路径

WindowsServiceTest.exe为Windows Service服务的应用程序,教程

Service1为服务名

ps:.bat与WindowsServiceTest.exe在同一路径


【出现问题】

在初始化安装时发生异常:

System.IO.FileNotFoundException: 未能加载文件或程序集“file:///F:\Windows”或它

的某一个依赖项。系统找不到指定的文件。。


原因:

路径中出现了空格


解决方案:文件放到没有空格的路径

eg:

F:\WindowsServiceTest_1_0_0_0\WindowsServiceTest.exe

你可能感兴趣的:(C#)