The process of installing a program into a Windows service and the problems encountered
Do a timed task of the program, to put it on the server, as a Windows service run, that is, log out, the user log off after the program still running in the background.
The steps to publish an EXE program as a service are logged as follows:
Scenario 1: No problem with program path
According to some online statements, enter the console, as follows (Victtec_maintain.exe is the program to be published):
C:\users\administrator>c:\windows\microsoft.net\framework\v2.0.50727\installutil.exe C:\maintain\VICTTEC_ Maintain.exe
Error:
An exception occurred during initialization of the installation:
System.badimageformatexception: Failed to load file or assembly "File:///c:\maintain\victtec_maintain.exe" or one of its dependencies. The runtime that generated this assembly is newer than the currently loaded run, and the process cannot be loaded
Where is the problem? According to the error message to see completely no clue, after a period of time thinking, think will be InstallUtil.exe This program version of the problem? So change the train of thought, leave v2.0.50727 this folder, enter
v4.0.30319 This version of the directory, run the command again, OK, success .
Scenario 2: Case where the program path itself is problematic
C:\users\administrator>c:\windows\microsoft.net\framework64\v4.0.30319\installutil.exe C:\Users\ Administrator\documents\visual Studio 2010projects\victtec_maintain\victtec_maintain\bin\debug\victtec_ Maintain.exe
Error:
Microsoft (R). NET Framework Installation Utility version 4.0.30319.1
Copyright (c) Microsoft Corporation. All rights reserved.
An exception occurred during initialization of the installation:
System.IO.FileNotFoundException: Failed to load file or assembly "file:///c:\users\administrator\documents\visual" or one of its dependencies. The system cannot find the file specified.
This error at first glance is also completely no clue, thinking for a long time, or from the error message, found that the error message prompted in the directory is incomplete, to "\visual" stopped, and the actual directory is \visual Studio,
As a result, guessing is not the path name of the space caused by the error, so the exe file transferred out, placed in the C:\maintain directory, that is, to ensure that the path name no space, try again, OK, success.
Summary: Many of the Windows system comes with the program is not perfect, there will be some small problems, to constantly change the angle to observe the problem, there is always a solution.
InstallUtil.exe version causes problems with installing the Windows Services service, System.badimageformatexception