You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 19, 2018. It is now read-only.
I recently updated my Visual Studio 2017 to 15.3 which means I got the opportunity to try out the new Core 2.0 SDK. It was easy enough but as soon as I tried running it as a Windows Service, I got into trouble.
I get a DLL as build output instead of an EXE (which kind of makes sense, being crossplatform, but the documentation clearly states it has to be an EXE)
when I run the DLL as a Windows Service, it fails to start
when I run the app either from VS2017 or with dotnet MyApp.dll, it throws an exception
The exception I get is:
Unhandled Exception: System.TypeLoadException: Could not load type 'System.ServiceProcess.ServiceBase' from assembly 'System.ServiceProcess, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
at Microsoft.AspNetCore.Hosting.WindowsServices.WebHostWindowsServiceExtensions.RunAsService(IWebHost host)
at Program.Main(String[] args) in C:\...\...\Program.cs:line 39
I have verified that all files from the build output are present, including Microsoft.AspNetCore.Hosting.WindowsServices.dll, so as far as I understand, everything should be there. Also, the System.ServiceProcess.dll file itself is present in all .NET framework installation directories.
Here's the target framework information:
<TargetFramework>netcoreapp2.0</TargetFramework>
Here's the Program.cs:
public class Program
{
public static void Main(string[] args)
{
var pathToExe = Process.GetCurrentProcess().MainModule.FileName;
var pathToContentRoot = Path.GetDirectoryName(pathToExe);
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(pathToContentRoot)
.UseIISIntegration()
.UseStartup<Startup>()
.UseApplicationInsights()
.Build();
host.RunAsService(); // <--- here is where the exception gets thrown
}
}
If this is a bug then can someone please confirm this behavior on their own machine?
If this is a feature then what should I do to get it working as intended?
I am experiencing this on a Windows 10 Professional (version 15063.540) running the latest stable Visual Studio 2017 (version 15.3) with .NET Core 2.0 SDK fully installed.
The text was updated successfully, but these errors were encountered:
I recently updated my Visual Studio 2017 to 15.3 which means I got the opportunity to try out the new Core 2.0 SDK. It was easy enough but as soon as I tried running it as a Windows Service, I got into trouble.
I have followed the official guideline https://docs.microsoft.com/en-us/aspnet/core/hosting/windows-service to the dot (no pun intended) but the new SDK seems to be different and possibly buggy:
dotnet MyApp.dll
, it throws an exceptionThe exception I get is:
I have verified that all files from the build output are present, including
Microsoft.AspNetCore.Hosting.WindowsServices.dll
, so as far as I understand, everything should be there. Also, theSystem.ServiceProcess.dll
file itself is present in all .NET framework installation directories.Here's the target framework information:
<TargetFramework>netcoreapp2.0</TargetFramework>
Here's the
Program.cs
:I am experiencing this on a Windows 10 Professional (version 15063.540) running the latest stable Visual Studio 2017 (version 15.3) with .NET Core 2.0 SDK fully installed.
The text was updated successfully, but these errors were encountered: