0

I have created a windows service and would like to test it however when I attempt to try and install the service using the developer command prompt I get this error:

Exception occurred while initializing the installation: System.IO.FileNotFoundException: Could not load file or assembly 'file:///C:\Program Files (x86)\Microsoft Visual Studio 14.0\BackUpService.exe' or one of its dependencies. The system cannot find the file specified..

the command i used was: installutil BackUpService.exe

I am not quite sure why I am getting this?

Vinod
  • 1,882
  • 2
  • 17
  • 27
  • http://stackoverflow.com/questions/10878602/system-io-filenotfoundexception-could-not-load-file-or-assembly-x-or-one-of-i – Damith Nov 22 '16 at 08:59
  • Is `BackUpService.exe` the executable of your service? If so, why should it be in a Visual Studio folder? – Bernhard Hiller Nov 22 '16 at 09:03
  • Yes the project is called DBBackupService and the service project itself is BackUpService. In terms of visual studio folder Im confused, currently though right now the project is in the c drive in a folder called dev in a folder called projects – Sheena Rawlinson Nov 22 '16 at 09:11
  • @SheenaRawlinson: can you please update your question with the command you have tried? – Vinod Nov 22 '16 at 09:53
  • @Vinod I have done this ^^^ – Sheena Rawlinson Nov 22 '16 at 09:57
  • http://stackoverflow.com/questions/8164859/install-a-windows-service-using-a-windows-command-prompt Also as stated by @nazmul-haque, you have to specify full path of you exe. – Vinod Nov 22 '16 at 10:00

3 Answers3

2

It's look like you just forgot install(-i) word.

C:\Windows\Microsoft.NET\Framework64\v4.0.30319>InstallUtil.exe -i C:\BackupProject\bin\Debug\BackupService.exe

Use -u for uninstall.

There is complete process of install & uninstall Windows Service on this link: https://stackoverflow.com/a/51788260/9888476

Karan Raiyani
  • 883
  • 6
  • 13
0

One way of figuring out what's missing here is by using Process Monitor. You would want to use the icons on the top right to limit the captured events to "Show File System Activity" only otherwise you'll get heaps of irrelevant information.

dnickless
  • 10,733
  • 1
  • 19
  • 34
  • I did what you recommended @dnickless and it starts however now i get this error :No public installers with the RunInstallerAttribute.Yes attribute could be found in the c:\Dev\Projects\DBBackUpService\DBBackUpService\bin\Debug\DBBackUpService.vshost.exe assembly. Remove InstallState file because there are no installers. The Commit phase completed successfully. The transacted install has completed. – Sheena Rawlinson Nov 22 '16 at 11:17
  • First i ran what you told me to do with the Process monitor to get the correct path which was: C:\Dev/Projects/DBBackUpService\DBBackUpService\bin\Debug\DBBackUpService.vshost.exe which brought back my error above... – Sheena Rawlinson Nov 22 '16 at 12:55
  • Then i cd'd into my dev and did it from there thinking it would work but it still didnt, ive seen it could have something to do with the run installer attribute but these are both put as Yes and public methods and still the same error. The good thing though is it removed the System.IO.file not found exception so i presume its something small i havent done that i may have over looked?? – Sheena Rawlinson Nov 22 '16 at 12:56
  • You do not want to register the file with the .vshost‌​.exe at the end - try the DB‌​BackUpService.exe! – dnickless Nov 22 '16 at 13:08
  • An exception occurred during the Install phase. System.Security.SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security. – Sheena Rawlinson Nov 22 '16 at 13:24
  • The Rollback phase of the installation is beginning. See the contents of the log file for the C:\Dev\Projects\DBBackUpService\DBBackUpService\bin\Debug\DBBackUpService.exe assembly's progress. The file is located at C:\Dev\Projects\DBBackUpService\DBBackUpService\bin\Debug\DBBackUpService.InstallLog. Rolling back assembly 'C:\Dev\Projects\DBBackUpService\DBBackUpService\bin\Debug\DBBackUpService.exe'. Affected parameters are: – Sheena Rawlinson Nov 22 '16 at 13:24
  • Have you got administrator permissions on the target machine? Are you running this command using elevated privileges? – dnickless Nov 22 '16 at 13:36
  • Legend! No i wasnt now its working an up and downloaded hahaha! the only thing now is i want to test it but not sure how to in debug mode. Furthermore, The service seems to stop when i start it which i presume is a problem in my code to try and find – Sheena Rawlinson Nov 22 '16 at 14:00
0

According to my understanding you are using InstallUtil.exe to install the windows service. In that case you have to specify full path of the windows service exe file in the command.

Like this

>InstallUtil.exe "C:\dev\DBBackupService\BackUpService.exe"

Hopefully this will work.