runtime icon indicating copy to clipboard operation
runtime copied to clipboard

Could not load or assemble system.serviceprocess.servicecontroller on windows services.

Open f3404923 opened this issue 4 years ago • 12 comments

Hi, I make a windows service with .net core. It happend some exception when the service start. Can you tell me how to solve it?

Application: MqttWorkerService.exe CoreCLR Version: 6.0.422.16404 .NET Version: 6.0.4 Description: The process was terminated due to an unhandled exception. Exception Info: System.IO.FileNotFoundException: Could not load file or assembly 'System.ServiceProcess.ServiceController, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. 系统找不到指定的文件。 File name: 'System.ServiceProcess.ServiceController, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' at Microsoft.Extensions.Hosting.WindowsServiceLifetimeHostBuilderExtensions.<>c__DisplayClass1_0.b__1(HostBuilderContext hostContext, IServiceCollection services) at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider() at Microsoft.Extensions.Hosting.HostBuilder.Build() at Program.
$(String[] args) in E:\source_code\C_Sharp\MQTTSniffServices\MqttWorkerService\Program.cs:line 3 at Program.
(String[] args)

this is my .net platform info: Host (useful for support): Version: 6.0.4 Commit: be98e88c76

.NET SDKs installed: No SDKs were found.

.NET runtimes installed: Microsoft.AspNetCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

My PC information: Microsoft Windows Server 2019 Datacenter Build 17763

f3404923 avatar Apr 28 '22 10:04 f3404923

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

ghost avatar Apr 28 '22 10:04 ghost

@f3404923 Is the System.ServiceProcess.ServiceController assembly on the machine? System.ServiceProcess.ServiceController appears to be an extension in .NET 6 so I don't believe it is included in NetCore.App.

It might be a useful exercise to try this outside of the Windows service scenario and enable tracing to determine where it is searching and why it isn't finding the assembly - see https://docs.microsoft.com/dotnet/core/dependency-loading/collect-details.

AaronRobinsonMSFT avatar Apr 28 '22 11:04 AaronRobinsonMSFT

Tagging subscribers to this area: @dotnet/area-extensions-hosting See info in area-owners.md if you want to be subscribed.

Issue Details

Hi, I make a windows service with .net core. It happend some exception when the service start. Can you tell me how to solve it?

Application: MqttWorkerService.exe CoreCLR Version: 6.0.422.16404 .NET Version: 6.0.4 Description: The process was terminated due to an unhandled exception. Exception Info: System.IO.FileNotFoundException: Could not load file or assembly 'System.ServiceProcess.ServiceController, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. 系统找不到指定的文件。 File name: 'System.ServiceProcess.ServiceController, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' at Microsoft.Extensions.Hosting.WindowsServiceLifetimeHostBuilderExtensions.<>c__DisplayClass1_0.b__1(HostBuilderContext hostContext, IServiceCollection services) at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider() at Microsoft.Extensions.Hosting.HostBuilder.Build() at Program.
$(String[] args) in E:\source_code\C_Sharp\MQTTSniffServices\MqttWorkerService\Program.cs:line 3 at Program.
(String[] args)

this is my .net platform info: Host (useful for support): Version: 6.0.4 Commit: be98e88c76

.NET SDKs installed: No SDKs were found.

.NET runtimes installed: Microsoft.AspNetCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

My PC information: Microsoft Windows Server 2019 Datacenter Build 17763

Author: f3404923
Assignees: -
Labels:

untriaged, area-Extensions-Hosting

Milestone: -

ghost avatar Apr 28 '22 11:04 ghost

@f3404923 - it will be easier to help if you could send the steps you used to produce this error. That way we can reproduce it ourselves to understand what the issue is. See https://github.com/dotnet/runtime/blob/main/CONTRIBUTING.md#writing-a-good-bug-report

eerhardt avatar Apr 28 '22 14:04 eerhardt

This issue has been marked needs-author-action since it may be missing important information. Please refer to our contribution guidelines for tips on how to report issues effectively.

ghost avatar Apr 28 '22 14:04 ghost

Tagging subscribers to this area: @dotnet/area-system-serviceprocess See info in area-owners.md if you want to be subscribed.

Issue Details

Hi, I make a windows service with .net core. It happend some exception when the service start. Can you tell me how to solve it?

Application: MqttWorkerService.exe CoreCLR Version: 6.0.422.16404 .NET Version: 6.0.4 Description: The process was terminated due to an unhandled exception. Exception Info: System.IO.FileNotFoundException: Could not load file or assembly 'System.ServiceProcess.ServiceController, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. 系统找不到指定的文件。 File name: 'System.ServiceProcess.ServiceController, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' at Microsoft.Extensions.Hosting.WindowsServiceLifetimeHostBuilderExtensions.<>c__DisplayClass1_0.b__1(HostBuilderContext hostContext, IServiceCollection services) at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider() at Microsoft.Extensions.Hosting.HostBuilder.Build() at Program.
$(String[] args) in E:\source_code\C_Sharp\MQTTSniffServices\MqttWorkerService\Program.cs:line 3 at Program.
(String[] args)

this is my .net platform info: Host (useful for support): Version: 6.0.4 Commit: be98e88c76

.NET SDKs installed: No SDKs were found.

.NET runtimes installed: Microsoft.AspNetCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

My PC information: Microsoft Windows Server 2019 Datacenter Build 17763

Author: f3404923
Assignees: -
Labels:

question, area-System.ServiceProcess, untriaged, needs-author-action

Milestone: -

ghost avatar Apr 28 '22 14:04 ghost

Thanks Sir @AaronRobinsonMSFT : I'm double confirm this file is included in the app's directory. I run my app directly with administrator account, the exception seems like same

Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'System.Diagnostics.EventLog, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. 系统找不到指定的文件。 File name: 'System.Diagnostics.EventLog, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' at Microsoft.Extensions.Logging.EventLog.EventLogSettings.CreateDefaultEventLog at Microsoft.Extensions.Logging.EventLog.EventLogSettings.get_EventLog at Microsoft.Extensions.Logging.EventLog.EventLogLogger..ctor(String name, EventLogSettings settings, IExternalScopeProvider externalScopeProvider) at Microsoft.Extensions.Logging.EventLog.EventLogLoggerProvider.CreateLogger(String name) at Microsoft.Extensions.Logging.LoggerFactory.CreateLoggers(String categoryName) at Microsoft.Extensions.Logging.LoggerFactory.CreateLogger(String categoryName) at Microsoft.Extensions.Logging.Logger1..ctor(ILoggerFactory factory) at System.RuntimeMethodHandle.InvokeMethod(Object target, Span1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions) at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope) at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(Type serviceType) at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope) at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider) at Microsoft.Extensions.Hosting.HostBuilder.b__28_2(IServiceProvider _) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope) at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(Type serviceType) at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope) at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider) at Microsoft.Extensions.Hosting.HostBuilder.Build() at Program.

$(String[] args) in E:\source_code\C_Sharp\MQTTSniffServices\MqttWorkerService\Program.cs:line 3 at Program.
(String[] args)

f3404923 avatar Apr 29 '22 00:04 f3404923

@f3404923 we would like to help you, but we don't have enough information.

Can you please provide a short sequence of steps we can follow in order to reproduce this problem?

Or, create a test app (with nothing confidential in it) that reproduces this, and put it in a public github repo so we can look at it.

Here are some relevant questions

  • What is the project targeting, eg., net60.
  • What package references are in the project.
  • Are you deploying it as a self contained app? https://docs.microsoft.com/en-us/dotnet/core/deploying/

Please follow the steps in https://github.com/dotnet/runtime/blob/main/CONTRIBUTING.md#writing-a-good-bug-report as recommended above.

danmoseley avatar Apr 29 '22 01:04 danmoseley

This issue has been marked needs-author-action since it may be missing important information. Please refer to our contribution guidelines for tips on how to report issues effectively.

ghost avatar Apr 29 '22 01:04 ghost

Thanks you @danmoseley

What is the project targeting, eg., net60.

My app is build on .net core 6.0, my target pc is windows datacenter 2019 build 17763(Just a VM)

What package references are in the project.

I reference 2 packages:

Microsoft.Extensions.Hosting.WindowsServices(v6.0.0); MQTTnet (v3.1.2)

Are you deploying it as a self contained app?

Yes, I am.

f3404923 avatar Apr 29 '22 01:04 f3404923

@f3404923 can you please construct a stand-alone repro? For example, a github repo that we can clone, and a command we should run to repro this? This repro should be simplified -- no code not required. for example, if MQTTnet is not required, then remove that and all the code. It's likely possible to make a very small program that repros this.

danmoseley avatar Apr 29 '22 02:04 danmoseley

I solved that compile and output to a alone file, No exception happened. But I don't know what is the root cause. Thanks everyone.

f3404923 avatar Apr 30 '22 06:04 f3404923