c# Windows Service does not work when publish with installutil.exe

0

I have a .net framework 4.6.1 application of type Windows Service, when I run the application locally it works. I publish in windows using the following command:

"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\installutil.exe" "C:\Bitworks\Git\pbxbitworks\PBX.WindowsService\bin\Release\PBX.WindowsService.exe"

The command failed with an exception of type System.InvalidOperationException: Cannot get installer types in assembly. when using Fusion Log I can observe the following

        *** Assembly Linkers Log Entry (5/20/2021 @ 6:06:46 PM) ***
    
    Operation failed.
    Link result: hr = 0x80070002. The system cannot find the specified file.
    
    The assembly manager was loaded from: C: \ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319 \ clr.dll
    Execution under executable file C: \ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319 \ InstallUtil.exe
    --- Detailed error log.
    
    === Status information before link ===
    LOG: DisplayName = System.Web.Http, Version = 5.2.7.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35
     (Fully-specified)
    LOG: Appbase = file: /// C: /Windows/Microsoft.NET/Framework64/v4.0.30319/
    LOG: Initial PrivatePath = NULL
    LOG: Dynamic base = NULL
    LOG: Cache Base = NULL
    LOG: AppName = InstallUtil.exe
    Call assembly: PBX.WindowsService, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = null.
    ===
    LOG: This link starts in the load context LoadFrom.
    AVS: The native image will not be parsed in the LoadFrom context. It will only be parsed in a default loading context, such as with Assembly.Load ().
    LOG: Using the application configuration file: C: \ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319 \ InstallUtil.exe.Config
    LOG: Using the host configuration file:
    LOG: Using the computer configuration file in C: \ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319 \ config \ machine.config.
    LOG: Post-directive reference: System.Web.Http, Version = 5.2.7.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35
    LOG: GAC search unsuccessful.
    LOG: Attempt to download the new URL file: /// C: /Windows/Microsoft.NET/Framework64/v4.0.30319/System.Web.Http.DLL.
    LOG: Attempt to download the new URL file: /// C: /Windows/Microsoft.NET/Framework64/v4.0.30319/System.Web.Http/System.Web.Http.DLL.
    LOG: Attempt to download the new URL file: /// C: /Windows/Microsoft.NET/Framework64/v4.0.30319/System.Web.Http.EXE.
    LOG: Attempt to download the new URL file: /// C: /Windows/Microsoft.NET/Framework64/v4.0.30319/System.Web.Http/System.Web.Http.EXE.
    LOG: Attempt to download the new URL file: /// C: /Bitworks/Git/pbxbitworks/PBX.WindowsService/bin/Release/System.Web.Http.DLL.
    LOG: Attempt to download the new URL file: /// C: /Bitworks/Git/pbxbitworks/PBX.WindowsService/bin/Release/System.Web.Http/System.Web.Http.DLL.
    LOG: Attempt to download new URL file: /// C: /Bitworks/Git/pbxbitworks/PBX.WindowsService/bin/Release/System.Web.Http.EXE.
    LOG: Attempt to download new URL file: /// C: /Bitworks/Git/pbxbitworks/PBX.WindowsService/bin/Release/System.Web.Http/System.Web.Http.EXE.
    LOG: All URLs were tried unsuccessfully.
    
    *** Assembly Linkers Log Entry (5/20/2021 @ 6:06:46 PM) ***
    
    Operation failed.
    Link result: hr = 0x80070002. The system cannot find the specified file.
    
    The assembly manager was loaded from: C: \ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319 \ clr.dll
    Execution under executable file C: \ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319 \ InstallUtil.exe
    --- Detailed error log.
    
    === Status information before link ===
    LOG: DisplayName = System.Web.Http, Version = 5.2.7.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35
     (Fully-specified)
    LOG: Appbase = file: /// C: /Windows/Microsoft.NET/Framework64/v4.0.30319/
    LOG: Initial PrivatePath = NULL
    LOG: Dynamic base = NULL
    LOG: Cache Base = NULL
    LOG: AppName = InstallUtil.exe
    Call assembly: PBX.WindowsService, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = null.
    ===
    LOG: This link starts in the load context LoadFrom.
    AVS: The native image will not be parsed in the LoadFrom context. It will only be parsed in a default loading context, such as with Assembly.Load ().
    LOG: Using the application configuration file: C: \ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319 \ InstallUtil.exe.Config
    LOG: Using the host configuration file:
    LOG: Using the computer configuration file in C: \ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319 \ config \ machine.config.
    LOG: Post-directive reference: System.Web.Http, Version = 5.2.7.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35
    LOG: GAC search unsuccessful.
    LOG: Attempt to download the new URL file: /// C: /Windows/Microsoft.NET/Framework64/v4.0.30319/System.Web.Http.DLL.
    LOG: Attempt to download the new URL file: /// C: /Windows/Microsoft.NET/Framework64/v4.0.30319/System.Web.Http/System.Web.Http.DLL.
    LOG: Attempt to download the new URL file: /// C: /Windows/Microsoft.NET/Framework64/v4.0.30319/System.Web.Http.EXE.
    LOG: Attempt to download the new URL file: /// C: /Windows/Microsoft.NET/Framework64/v4.0.30319/System.Web.Http/System.Web.Http.EXE.
    LOG: Attempt to download the new URL file: /// C: /Bitworks/Git/pbxbitworks/PBX.Win

*** Assembly linkers log entry (5/20/2021 @ 12:37:55) ***

Operation failed.
Link result: hr = 0x80070002. The system cannot find the specified file.

The assembly manager was loaded from: C: \ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319 \ clr.dll
Execution under executable file C: \ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319 \ InstallUtil.exe
--- Detailed error log.

=== Status information before link ===
LOG: DisplayName = InstallUtil.resources, Version = 4.0.0.0, Culture = en-ES, PublicKeyToken = b03f5f7f11d50a3a
 (Fully-specified)
LOG: Appbase = file: /// C: /Windows/Microsoft.NET/Framework64/v4.0.30319/
LOG: Initial PrivatePath = NULL
LOG: Dynamic base = NULL
LOG: Cache Base = NULL
LOG: AppName = InstallUtil.exe
Call assembly: InstallUtil, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a.
===
LOG: This link starts in the default load context.
LOG: Using the application configuration file: C: \ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319 \ InstallUtil.exe.Config
LOG: Using the host configuration file:
LOG: Using the computer configuration file in C: \ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319 \ config \ machine.config.
LOG: Post-directive reference: InstallUtil.resources, Version = 4.0.0.0, Culture = en-ES, PublicKeyToken = b03f5f7f11d50a3a
LOG: The same link was already detected, which generated an error hr = 0x80070002.
ERR: Unrecoverable error during pre-download check (hr = 0x80070002).

My application has an OWIN Self-Host API and I use swagger on that API with Swashbuckle.Core 5.6.0 package and I also have Microsoft.AspNet.WebApi.Core 5.2.7 package installed.

Interestingly, when uninstalling Swashbuckle.Core, the installation of the windows service is successful. Could anyone please guide me on how I could make these two packages exist in the same project without conflict?

For my project, using Swagger is required and as I understand the way to use swagger in your own self-hosting api is to use Swashbuckle.Core.

c#
.net
windows-services
.net-framework-version
asked on Stack Overflow May 21, 2021 by Davis Cruz

1 Answer

0

UPDATE:

installutil is the only one that gives me problems with the dlls when creating the windows service, the command

sc create ServiceName binPath = "fullservicepath.exe"

It works for me, until I find the installutil solution

answered on Stack Overflow May 21, 2021 by Davis Cruz

User contributions licensed under CC BY-SA 3.0