canton7 / Stylet

A very lightweight but powerful ViewModel-First MVVM framework for WPF for .NET Framework and .NET Core, inspired by Caliburn.Micro.
MIT License
995 stars 144 forks source link

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

Closed kuangxj closed 1 year ago

kuangxj commented 1 year ago

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

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.

kuangxj commented 1 year ago

I found the problem。