'Grpc: C# server as a Windows Service is it possible?

Im trying to pass the source code of a C# Grpc server into a Windows Service Project. Following these steps but when I execute InstallUtil MyService.exe the process stops indicating

System.Reflection.ReflectionTypeLoadException: No se pueden cargar uno o varios
tipos requeridos. Recupere la propiedad LoaderExceptions para obtener más información.

How can I solve it?



Solution 1:[1]

Try setting the Copy Local attribute of project's references to true.

More info here: Error message 'Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.'

Solution 2:[2]

InstallUtil is for installation of windows service, which we are using earlier for .net framework. As this will be in .net Core, we need to use a cs command.

Following is the example command you can use:

sc.exe create NewServiceName binpath=pathOfExe

You need to use a CS command as specified in following link because this is a .net Core application.

https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/sc-create

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Community
Solution 2 ouflak