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
Service installation attempt gives Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
#104
I am working in VS 2017, and I create a new console app in .Net Core 2.1. I use the nuget package manager to add PeterKottas.DotNetCore.WindowsService to my dependencies. Then I paste your example into Program.cs:
using System;
using System.Runtime;
using PeterKottas.DotNetCore.WindowsService;
using PeterKottas.DotNetCore.WindowsService.Interfaces;
namespace KottasTest
{
class Program
{
static void Main(string[] args)
{
ServiceRunner.Run(config =>
{
var name = config.GetDefaultName();
config.Service(serviceConfig =>
{
serviceConfig.ServiceFactory((extraArguments, x) =>
{
return new ExampleService();
});
serviceConfig.OnStart((service, extraArguments) =>
{
Console.WriteLine("Service {0} started", name);
service.Start();
});
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
If I add an app.config file such as below, to try to do a binding redirect, the result is still an error.
”
to try a binding redirect to the version of System.Runtime that I see in my nuget packages folder (under my profile), which is 4.3.0.0, it fails as shown below:
=============================
Microsoft Windows [Version 10.0.17134.254]
(c) 2018 Microsoft Corporation. All rights reserved.
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
--- End of inner exception stack trace ---
P.S. I do not know why my description got formatted so oddly. Also I put in the xml of the app.config file but that seems to have disappeared from the description (maybe it doesn't like xml?).
From Readme:
20. "Install the service using powershell: dotnet.exe $serviceDllPath action:install"
You can also try dotnet run action:install from project folder
I am working in VS 2017, and I create a new console app in .Net Core 2.1. I use the nuget package manager to add PeterKottas.DotNetCore.WindowsService to my dependencies. Then I paste your example into Program.cs:
using System;
using System.Runtime;
using PeterKottas.DotNetCore.WindowsService;
using PeterKottas.DotNetCore.WindowsService.Interfaces;
namespace KottasTest
{
class Program
{
static void Main(string[] args)
{
ServiceRunner.Run(config =>
{
var name = config.GetDefaultName();
config.Service(serviceConfig =>
{
serviceConfig.ServiceFactory((extraArguments, x) =>
{
return new ExampleService();
});
serviceConfig.OnStart((service, extraArguments) =>
{
Console.WriteLine("Service {0} started", name);
service.Start();
});
}
This runs as a console application, but when I attempt to install using the console (running as admin), it fails as shown below:
=============================
Microsoft Windows [Version 10.0.17134.254]
(c) 2018 Microsoft Corporation. All rights reserved.
C:\WINDOWS\system32>cd C:\AdTech\Repos\KottasTestSolution\KottasTest\bin\Debug\netcoreapp2.1
C:\AdTech\Repos\KottasTestSolution\KottasTest\bin\Debug\netcoreapp2.1>KottasTest.dll action:install
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
C:\AdTech\Repos\KottasTestSolution\KottasTest\bin\Debug\netcoreapp2.1>
If I add an app.config file such as below, to try to do a binding redirect, the result is still an error.
”to try a binding redirect to the version of System.Runtime that I see in my nuget packages folder (under my profile), which is 4.3.0.0, it fails as shown below:
=============================
Microsoft Windows [Version 10.0.17134.254]
(c) 2018 Microsoft Corporation. All rights reserved.
C:\WINDOWS\system32>cd C:\AdTech\Repos\KottasTestSolution\KottasTest\bin\Debug\netcoreapp2.1
C:\AdTech\Repos\KottasTestSolution\KottasTest\bin\Debug\netcoreapp2.1>KottasTest.dll action:install
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
--- End of inner exception stack trace ---
C:\AdTech\Repos\KottasTestSolution\KottasTest\bin\Debug\netcoreapp2.1>
Because the sample app is so simple, I am not sure what can be going on here. This seems very weird.
Thanks for any help you can offer.
The text was updated successfully, but these errors were encountered: