canton7 / Stylet

A very lightweight but powerful ViewModel-First MVVM framework for WPF for .NET Framework and .NET Core, inspired by Caliburn.Micro.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

referencing grpc.net.client in the project, error CS0234 is reported.

kuangxj opened this issue · comments

Description
A clear and concise description of what the bug is. Use screenshots as necessary.

To Reproduce
Code to reproduce the bug, which someone else can run.

Version Info

  • Stylet version: [e.g. 1.2.3]
  • Runtime version: [e.g. 5.0.300]

Additional Info
Add any other context about the problem here.

// code e.g.
internal class Bootstrapper : Bootstrapper
{
var clientCertificate = new X509Certificate2(Path.Combine(Environment.CurrentDirectory, "****.pfx"), "1111");
var handler = new HttpClientHandler();
handler.ClientCertificates.Add(clientCertificate);
// one
handler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
// two
//handler.ServerCertificateCustomValidationCallback = (a, b, c, d) => true

    var http3handler = new Http3Handler(handler);
    //  gRpc channel settings
    var grpcChannelOptions = new GrpcChannelOptions { HttpHandler = http3handler };
    GrpcChannel? grpcChannel = GrpcChannel.ForAddress("http://localhost:5124", grpcChannelOptions);
   //  Accounter.AccounterClient is gRpc auto-generated
    builder.Bind<Accounter.AccounterClient>().ToFactory(o => new  Accounter.AccounterClient(grpcChannel)).InSingletonScope();

}

internal class Http3Handler : DelegatingHandler
{
    public Http3Handler() { }
    public Http3Handler(HttpMessageHandler innerHandler) : base(innerHandler) { }

    protected override Task<HttpResponseMessage> SendAsync(
        HttpRequestMessage request, CancellationToken cancellationToken)
    {
        request.Version = HttpVersion.Version30;
        request.VersionPolicy = HttpVersionPolicy.RequestVersionExact;

        return base.SendAsync(request, cancellationToken);
    }
}

When vs2022 debug,the output window error:error CS0234:…… so don't run debug or release.

I found the problem。