@@ -185,19 +185,9 @@ internal GrpcChannel(Uri address, GrpcChannelOptions channelOptions) : base(addr
185185            Log . AddressPathUnused ( Logger ,  Address . OriginalString ) ; 
186186        } 
187187
188-         // Grpc.Net.Client + .NET Framework + WinHttpHandler requires features in WinHTTP, shipped in Windows, to work correctly. 
189-         // This scenario is supported in these versions of Windows or later: 
190-         // -Windows Server 2022 has partial support. 
191-         //    -Unary and server streaming methods are supported. 
192-         //    -Client and bidi streaming methods aren't supported. 
193-         // -Windows 11 has full support. 
194-         // 
195-         // GrpcChannel validates the Windows version is WinServer2022 or later. Win11 version number is greater than WinServer2022. 
196-         // Note that this doesn't block using unsupported client and bidi streaming methods on WinServer2022. 
197-         const  int  WinServer2022BuildVersion  =  20348 ; 
198188        if  ( HttpHandlerType  ==  HttpHandlerType . WinHttpHandler  && 
199189            OperatingSystem . IsWindows  && 
200-             OperatingSystem . OSVersion . Build   <   WinServer2022BuildVersion ) 
190+             ! ValidateWinHttpHandlerOperatingSystemVersion ( ) ) 
201191        { 
202192            throw  new  InvalidOperationException ( "The channel configuration isn't valid on this operating system. "  + 
203193                "The channel is configured to use WinHttpHandler and the current version of Windows "  + 
@@ -206,6 +196,34 @@ internal GrpcChannel(Uri address, GrpcChannelOptions channelOptions) : base(addr
206196        } 
207197    } 
208198
199+     private  bool  ValidateWinHttpHandlerOperatingSystemVersion ( ) 
200+     { 
201+         // Grpc.Net.Client + .NET Framework + WinHttpHandler requires features in WinHTTP, shipped in Windows, to work correctly. 
202+         // This scenario is supported in these versions of Windows or later: 
203+         // -Windows Server 2019 and Windows Server 2022 have partial support. 
204+         //    -Unary and server streaming methods are supported. 
205+         //    -Client and bidi streaming methods aren't supported. 
206+         // -Windows 11 has full support. 
207+         const  int  WinServer2022BuildVersion  =  20348 ; 
208+         const  int  WinServer2019BuildVersion  =  17763 ; 
209+ 
210+         // Validate the Windows version is WinServer2022 or later. Win11 version number is greater than WinServer2022. 
211+         // Note that this doesn't block using unsupported client and bidi streaming methods on WinServer2022. 
212+         if  ( OperatingSystem . OSVersion . Build  >=  WinServer2022BuildVersion ) 
213+         { 
214+             return  true ; 
215+         } 
216+ 
217+         // Validate the Windows version is WinServer2019. Its build numbers are mixed with Windows 10, so we must check 
218+         // the OS version is Windows Server and the build number together to avoid allowing Windows 10. 
219+         if  ( OperatingSystem . IsWindowsServer  &&  OperatingSystem . OSVersion . Build  >=  WinServer2019BuildVersion ) 
220+         { 
221+             return  true ; 
222+         } 
223+ 
224+         return  false ; 
225+     } 
226+ 
209227    private  void  ResolveCredentials ( GrpcChannelOptions  channelOptions ,  out  bool  isSecure ,  out  List < CallCredentials > ?  callCredentials ) 
210228    { 
211229        if  ( channelOptions . Credentials  !=  null ) 
0 commit comments