Skip to content

Can't create channel in UWP app in Release mode #2375

@michalleptuch

Description

@michalleptuch

What version of gRPC and what language are you using?

Grpc.Net.Client 2.61.0
Grpc.Net.Client.Web 2.61.0

What operating system (Linux, Windows,...) and version?

Windows 11 23H2 22631.3155

What runtime / compiler are you using (e.g. .NET Core SDK version dotnet --info)

.NET Native (UWP)

What did you do?

I used this tutorial to create gRPC channel in UWP app: https://learn.microsoft.com/en-us/aspnet/core/grpc/netstandard. Everything works fine in Debug mode. The problem occurs when my app is installed using MSIX package (and works in Release mode).

var channel = GrpcChannel.ForAddress($"http://localhost:{port}", new GrpcChannelOptions
{
  HttpHandler = new GrpcWebHandler(new HttpClientHandler()),
});

return channel.CreateGrpcService<T>();

What did you expect to see?

Working channel

What did you see instead?

Exception message:

Unresolved P/Invoke method 'ntdll.dll!RtlGetVersion' from this method. Please look for this method in build warnings for more details. 

and stack trace:

at __Interop.ntdll_dll.RtlGetVersion(OSVERSIONINFOEX& versionInfo)
at Grpc.Net.Client.Internal.NtDll.DetectWindowsVersion(Version& version, Boolean& isWindowsServer) in /_/src/Grpc.Net.Client/Internal/NtDll.cs:line 40
at Grpc.Net.Client.Internal.OperatingSystem..ctor() in /_/src/Grpc.Net.Client/Internal/OperatingSystem.cs:line 77
at Grpc.Net.Client.Internal.OperatingSystem..cctor() in /_/src/Grpc.Net.Client/Internal/OperatingSystem.cs:line 34
at System.Runtime.CompilerServices.ClassConstructorRunner.EnsureClassConstructorRun(StaticClassConstructionContext* pContext) in f:\dd\ndp\fxcore\CoreRT\src\System.Private.CoreLib\src\System\Runtime\CompilerServices\ClassConstructorRunner.cs:line 92

Anything else we should know about your project / environment?

The problem occurs in NtDll.cs file invoked here:

NtDll.DetectWindowsVersion(out var windowsVersion, out var windowsServer);

UWP platform cannot use RtlGetVersion method from ntdll.dll because it's not allowed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions