Closed cheesi closed 3 years ago
@cheesi Interesting. Were you able to try any other Windows machine?
Also, are you able to creaate an isolated repro app so that we can investigate on our side?
As I already mentioned, I didn't had the time to test it on another windows machine, but i will try that now.
The code of the application is closed company source, so I'm not really able to share much of it, but I will setup a new ASP.NET Core project with windows service hosting and try to figure out, if it's the code of our application or my dev machine.
@cheesi sounds good, thanks!
I tried it on a second dev machine now and I got the same error. I going to setup a fresh repo now.
I figured out the problem.
I was publishing with VS and my publish profile set to "Framework Dependent", but it seems to only work with "Self Contained".
Is there a specific reason for that?
@cheesi interesting. @Tratcher thoughts?
It should work either way. It sounds like the right dependency isn't getting published. We do depend on a special dependency out of the Windows Compat Pack, System.ServiceProcess.ServiceController, so if that's not getting published and you end up with a placeholder that would explain the PlatformNotSupportedExceptionon.
Do you have a project handy you can share on github? Or is it just one of the doc sample apps?
I set up a new ASP.NET repo with windows service hosting and that worked with both publish options. Unfortunately, i got two very important tasks today, so I need to put this on hold. When i have more time, I will continue investigating this issue.
@cheesi did you find the issue what was causing, as im facing the same issue now, i tried changing to self contained still facing the same error, here im running the solution in AKS cluster, getting the same error, what is ideal setting for publishing dotnet core app on Azure AKS container.
Unhandled Exception: System.PlatformNotSupportedException: ServiceController enables manipulating and accessing Windows services and it is not applicable for other operating systems. at System.ServiceProcess.ServiceBase..ctor()
@shivashankar-awanti sorry, I didn't had the time to investigate this error further. Currently I have so many tasks. I will share any infos here, if I know something new.
@shivashankar-awanti this bug is about Windows. I'm assuming you're running Linux containers in your AKS cluster.
@muratg yes, the containers are Linux. Is there any solution for this bug?
@shivashankar-awanti don't use the RunAsService method, it's specifically for Windows services. Use Run instead.
@davidfowl im using ServiceBase.Run(servicesToRun) to start the service, but same issue.
Why are you using ServiceBase at all on linux, don't use it, it isn't for that purpose. Just use the normal Run method.
@davidfowl under which namespace is Run method which you are talking about, as im writing in this way by creating list of services which needs to be run as a instance of ServiceBase and im looping it to run one by one. if i dont use ServiceBase, what would be other approach.
@shivashankar-awanti I'm not sure what you're trying to do. Are you trying to write a console application on linux?
@davidfowl yes, but normal console application works but when im trying to use ServiceBase its causing issue.
ServiceBase is WINDOWS ONLY. It is there to interact with WINDOWS service interface. IT IS NOT FOR LINUX.
@cheesi and @davidfowl Thanks for the info, but is there any other way to implement, same as ServiceBase which supports Linux Container.
@cheesi were you able to get this working as "Framework Dependent"? I am having the same issue and I did make sure that System.ServiceProcess.ServiceController.dll was being published.
Hey @FrankPeach! Nay, sorry. As this is just my side project and I had so many other things todo, I still didn't had the time to investigate this issue.
One possibility might be to wait for .NET Core 3.0, as there will be changes regarding the build/publish tasks.
Let me know, if you got anything new.
Got this error on ASP.NET Core 2.2 (Self Contained) after including package reference
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.1" />
When I remove it, service runs successfully.
OS is Windows Server 2008 R2
Hope that helps.
I had the same issue, the problem was the namespace : the name of the .exe file generated contained a dot : MySolution.Test.exe (won't work) => MySolutionTest.exe (works)
Just to add what solved the issue for me. I have a project like dotnet thats a CLI tool for in house devops related things. This tool uses chocolatey to install individual commands in to their own folder. It then uses some reflection and command line parsing to call in to these commands.
Since the commands are in their own folders outside of the main exe, I have used the assembly event to look for DLLs that can't be found in the main exe path. For some reason the main exe path already has a stubbed out version of System.ServiceProcess when doing a self containied deploy/publish even though it was not used anywhere. This was leading to reflection load that DLL instead of the real one in the command's folder.
Once I added the nuget for System.ServiceProcess to the main project that handles command delegation the error went away and started properly. I only came to try this based on what @Tratcher said above.
My suggestion is to provide a better error message. Prior to saying "OS not supported", perhaps it should check to see if you are on windows or a supported OS and report that this is some sort of stub library and to add the nuget reference?
I got this error message on Windows Server 2019 with .NET Core 3.1 when I failed to copy the runtimes folder along with the self-contained executable and DLLs.
I forgot to copy the xxx.deps.json file and it also leads to this issue. (.NET Core 3.1)
@Larry57 https://github.com/dotnet/aspnetcore/issues/5934#issuecomment-644003133 This works for me.
If this still repros using the generic host, file an issue on dotnet/runtime. I believe I saw a similar issue related to nuget packages and files being overwritten on publish (I can't find it right now).
Hello!
I'm facing a very strange issue. Currently I'm porting our .Net Framework windows service to ASP.NET Core. For the windows service part, i have been following this tutorial: https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/windows-service?view=aspnetcore-2.1
However the
host.RunAsService()
throws aPlatformNotSupportedException
on my windows dev machine (i didn't had the time to test it somewhere else).The code isn't very spectacular:
Info: