In Greet.cs, “using System;” is missing and string.Concat should change to String.Concat
In VC# at least for this to compile
Hmm, “Using System” is implied in Elements, so that should make no difference. same for lowercase string (keyword) vs uppercase String (type name).
but that said, I don’t generate that code, and have no influence over it. This doesn’t seem to relate t the errors I’m getting, though.
I could not find your account to upload the new build. DM me?
- Internal User ID: fcad23c6-1cc6-4956-b984-133620026be4
Ah, among the four accounts that’s the one I missed ;). New build it up.
sorry, but only see 2763 & 2771.
there is a hidden corner?
Yes, it’s in your personal downloads, not a general release. remobjects.com/portal/downloads/personal.
Great, thank you.
I have the same four mistakes as you.
I did a differential between the files generated by VS and Water, apart from the folder name “Protos” which is not included, there is not a comma difference.
On server 2022, the tools use x86 and not x64 but after testing, this does not change anything either.
In Water, there is a yellow exam point to the left of Grpc.Tools and nothing underneath, whereas in VS it includes the Grpc.Tools.props and targets build files.
ps: I can now edit the proto files
I wonder if this is a legit compiler issue? Can yu try if the same set of files (manually copied) work in a VC#?
Yeah, the warning is because Grpc.Tools
has no deliverables for the build (aside from the tools, which is handled by a different task than the reference resolver). it can be ignored; I suppose one could debate of I should emit this warning or not…
Tested and confirmed that the files produced by Water (C:\Users\Administrator\AppData\Local\RemObjects Software\EBuild\Obj\7CE1A8A410A552CEBC9FA16E4F606665CC0E0E8A\Debug\Echoes\ProtoBuffers) compile in VS and the server responds normally.
Concerning Grpc.Tools, it was only for info
Ok, I;ll log a compiler bug
Logged as bugs://E26146.
FYI, yesterday I made a cast on each of the four declarations for compilation and the server crashed during the client call
yeah, those assignment do seem wrong, intuitively. what was the crash, “invalid typecast”?
I’ll have to see eider Carlo has any better ideas, as I dont understand how this is supposed to compile, as “Grpc.Core.Marshaller<Google.Protobuf.IMessage>
” and “Grpc.Core.Marshaller<HelloRequest>
” are not compatible types.
it looks like maybe
grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::GrpcService1.HelloRequest.Parser)); /
infers the wrong generic parameter for Create<T>
…
exactly the same message as before the cast, "Type mismatch, except “Grpc.Core.Marshaller<blabla…>”
Microsoft.AspNetCore.Hosting.Diagnostics[6]
Application startup exception
System.InvalidOperationException: Error binding gRPC service 'GreeterService'.
---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.TypeInitializationException: The type initializer for 'GrpcServiceSrv.Greeter' threw an exception.
---> System.InvalidCastException: Unable to cast object of type 'Grpc.Core.Marshaller`1[Google.Protobuf.IMessage]' to type 'Grpc.Core.Marshaller`1[GrpcServiceSrv.HelloRequest]'.
at GrpcServiceSrv.Greeter..cctor()
--- End of inner exception stack trace ---
at GrpcServiceSrv.Greeter.BindService(ServiceBinderBase serviceBinder, GreeterBase serviceImpl)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at Grpc.AspNetCore.Server.Model.Internal.BinderServiceMethodProvider`1.OnServiceMethodDiscovery(ServiceMethodProviderContext`1 context)
--- End of inner exception stack trace ---
at Grpc.AspNetCore.Server.Model.Internal.BinderServiceMethodProvider`1.OnServiceMethodDiscovery(ServiceMethodProviderContext`1 context)
at Grpc.AspNetCore.Server.Model.Internal.ServiceRouteBuilder`1.Build(IEndpointRouteBuilder endpointRouteBuilder)
at Microsoft.AspNetCore.Builder.GrpcEndpointRouteBuilderExtensions.MapGrpcService[TService](IEndpointRouteBuilder builder)
at GrpcServiceSrv.Startup.<Configure>b__0(IEndpointRouteBuilder endpoints)
at Microsoft.AspNetCore.Builder.EndpointRoutingApplicationBuilderExtensions.UseEndpoints(IApplicationBuilder builder, Action`1 configure)
at GrpcServiceSrv.Startup.Configure(IApplicationBuilder app, IWebHostEnvironment env)
at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)
at Microsoft.AspNetCore.Hosting.ConfigureBuilder.<>c__DisplayClass4_0.<Build>b__0(IApplicationBuilder builder)
at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass15_0.<UseStartup>b__1(IApplicationBuilder app)
at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
Unhandled exception. System.InvalidOperationException: Error binding gRPC service 'GreeterService'.
---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.TypeInitializationException: The type initializer for 'GrpcServiceSrv.Greeter' threw an exception.
---> System.InvalidCastException: Unable to cast object of type 'Grpc.Core.Marshaller`1[Google.Protobuf.IMessage]' to type 'Grpc.Core.Marshaller`1[GrpcServiceSrv.HelloRequest]'.
at GrpcServiceSrv.Greeter..cctor()
--- End of inner exception stack trace ---
at GrpcServiceSrv.Greeter.BindService(ServiceBinderBase serviceBinder, GreeterBase serviceImpl)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at Grpc.AspNetCore.Server.Model.Internal.BinderServiceMethodProvider`1.OnServiceMethodDiscovery(ServiceMethodProviderContext`1 context)
--- End of inner exception stack trace ---
at Grpc.AspNetCore.Server.Model.Internal.BinderServiceMethodProvider`1.OnServiceMethodDiscovery(ServiceMethodProviderContext`1 context)
at Grpc.AspNetCore.Server.Model.Internal.ServiceRouteBuilder`1.Build(IEndpointRouteBuilder endpointRouteBuilder)
at Microsoft.AspNetCore.Builder.GrpcEndpointRouteBuilderExtensions.MapGrpcService[TService](IEndpointRouteBuilder builder)
at GrpcServiceSrv.Startup.<Configure>b__0(IEndpointRouteBuilder endpoints)
at Microsoft.AspNetCore.Builder.EndpointRoutingApplicationBuilderExtensions.UseEndpoints(IApplicationBuilder builder, Action`1 configure)
at GrpcServiceSrv.Startup.Configure(IApplicationBuilder app, IWebHostEnvironment env)
at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)
at Microsoft.AspNetCore.Hosting.ConfigureBuilder.<>c__DisplayClass4_0.<Build>b__0(IApplicationBuilder builder)
at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass15_0.<UseStartup>b__1(IApplicationBuilder app)
at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
at GrpcServiceSrv.Program.Main(String[] args)
makes sense. at least compiler and runtime agree that these two aren’t compatible
I can’t find anything more to test on my side.
I created a client and “Grpc.Tools” does not integrate under Grpc.Net.Client, you must add Grpc.aspnetcore (useful only for Grpc server) to have the same compilation error
Yeah, we’re pretty sure it’s a compiler bug, something related to generic variance on delegates. Unfortunately, it’s not a “quick fix”, so I’m afraid it might have to wait until some time next week to get addressed properly.
Got it narrowed down nice and clean though… wasn’t easy
public interface IMessage {
}
public interface IMessage<T> : IMessage {
}
public class MessageParser
{
}
public sealed class MessageParser<HelloRequest> : MessageParser
{
}
public sealed partial class HelloRequest : IMessage<HelloRequest>
{
public static MessageParser<HelloRequest> Parser { get { return null; } }
}
public class Marshaller<T>
{
}
public static abstract sealed class Marshallers : object
{
public Marshaller<T> Create<T>(Action<T, IMessage> serializer, Func<IMessage,T> deserializer)
{
}
}
public static partial class Greeter
{
static void __Helper_SerializeMessage(IMessage message, object context)
{
}
static void __Helper_DeserializeMessage(IMessage message, object context)
{
}
static readonly Marshaller<HelloRequest> __Marshaller_greet_HelloRequest =
Marshallers.Create( // E62 Type mismatch, cannot assign "Marshaller<IMessage>" to "Marshaller<HelloRequest>"
__Helper_SerializeMessage, context =>
__Helper_DeserializeMessage(context, HelloRequest.Parser));
}
Great!
one more track maybe, it’s rare for a nudget package to ship a specific msbuild. it would not be used, at compilation, to compile the proto file to IMessage?