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
In a .NET 6 Windows service application, we have a reference to the class 'System.ServiceProcess.ServiceBase' from 'System.ServiceProcess.ServiceController.dll'. However, when we decompile the code, we notice that the methods appear to be throwing unsupported exceptions, as shown in the sample code below:
public ServiceBase() { throw new System.PlatformNotSupportedException(System.SR.PlatformNotSupported_ServiceController); } protected virtual void OnStart(string[] args) { throw new System.PlatformNotSupportedException(System.SR.PlatformNotSupported_ServiceController); } protected virtual void OnStop() { throw new System.PlatformNotSupportedException(System.SR.PlatformNotSupported_ServiceController); }
Interestingly, we do not encounter any exceptions at runtime, even though we are instantiating the ServiceBase class.
question is: Is the ServiceBase class truly unsupported in .NET 6 on Windows platform ? If it is unsupported, why are there no exceptions thrown at runtime when using it?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
In a .NET 6 Windows service application, we have a reference to the class 'System.ServiceProcess.ServiceBase' from 'System.ServiceProcess.ServiceController.dll'. However, when we decompile the code, we notice that the methods appear to be throwing unsupported exceptions, as shown in the sample code below:
public ServiceBase() { throw new System.PlatformNotSupportedException(System.SR.PlatformNotSupported_ServiceController); } protected virtual void OnStart(string[] args) { throw new System.PlatformNotSupportedException(System.SR.PlatformNotSupported_ServiceController); } protected virtual void OnStop() { throw new System.PlatformNotSupportedException(System.SR.PlatformNotSupported_ServiceController); }
Interestingly, we do not encounter any exceptions at runtime, even though we are instantiating the ServiceBase class.
question is: Is the ServiceBase class truly unsupported in .NET 6 on Windows platform ? If it is unsupported, why are there no exceptions thrown at runtime when using it?
Beta Was this translation helpful? Give feedback.
All reactions