Open Roy-se7en opened 1 year ago
OrderDto
? (so I can assess what I would expect it to do)if I don't use below code, it work well
context.Services.AddCodeFirstGrpcReflection(); ... app.MapCodeFirstGrpcReflectionService();
/// <summary>
/// 列表项
/// </summary>
[ProtoContract]
public class OrderDto : OrderOutData
{
/// <summary>
/// 交期
/// </summary>
[ProtoMember(1)]
public decimal? ProduceCycle { get; set; }
/// <summary>
/// 交易货币
/// </summary>
[ProtoMember(2)]
public string Currency { get; set; }
/// <summary>
/// 交易货币汇率
/// </summary>
[ProtoMember(3)]
public decimal ExchangeRate { get; set; }
...
}
/// <summary>
/// 基础信息
/// </summary>
[ProtoContract]
[ProtoInclude(200, typeof(OrderDto))]
public class OrderOutData
{
/// <summary>
/// 询盘/订单Id
/// </summary>
[ProtoMember(1)]
public long Id { get; set; }
/// <summary>
/// 客户id
/// </summary>
[ProtoMember(2)]
public long MemberId { get; set; }
/// <summary>
/// 合伙人组织Id
/// </summary>
[ProtoMember(3)]
public long CopartnerOrgId { get; set; }
...
}
I ran into the same (or a similar) issue literally 20 minutes ago.
This fails:
[ServiceContract]
public interface IFooService
{
[OperationContract]
public ValueTask<FooResponse> Foo(FooRequest req);
// other methods
}
[ProtoContract]
public sealed class FooResponse
{
[ProtoMember(1)]
public bool Exists { get; set; }
[ProtoMember(2)]
public LocalDate? PlanningStart { get; set; }
[ProtoMember(3)]
public LocalDate? PlanningEnd { get; set; }
}
with the following error:
System.InvalidOperationException: No marshaller available for Initech.Shared.Contract.Endpoints.FooResponse
at ProtoBuf.Grpc.Internal.MarshallerCache.<GetMarshaller>g__Throw|5_0[T]() in /_/src/protobuf-net.Grpc/Internal/MarshallerCache.cs:line 39
at ProtoBuf.Grpc.Internal.MarshallerCache.GetMarshaller[T]() in /_/src/protobuf-net.Grpc/Internal/MarshallerCache.cs:line 36
at ProtoBuf.Grpc.Configuration.ServerBinder.AddMethod[TService,TRequest,TResponse](String serviceName, String operationName, MethodInfo method, MethodType methodType, ServiceBindContext bindContext, Func`3 invoker, MarshallerCache marshallerCache, ConstantExpression service, Boolean simplfiedExceptionHandling) in /_/src/protobuf-net.Grpc/Configuration/ServerBinder.cs:line 251
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodBaseInvoker.InvokeWithManyArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
Yet this works:
[ServiceContract]
public interface IFooService
{
[OperationContract]
public ValueTask<Bar> Foo(FooRequest req);
// other methods
}
[ProtoContract]
public sealed class Bar
{
[ProtoMember(1)]
public required FooResponse Baz {get; set;}
}
[ProtoContract]
public sealed class FooResponse
{
[ProtoMember(1)]
public bool Exists { get; set; }
[ProtoMember(2)]
public LocalDate? PlanningStart { get; set; }
[ProtoMember(3)]
public LocalDate? PlanningEnd { get; set; }
}
I had another issue yesterday where simply wrapping an object made an issue go away, which I can't explain.
OK, that's weird; I'll investigate
OK, that's weird; I'll investigate
Thanks a lot! If it helps I could probably send you the contract DLL and the server setup code, but I can't post it somewere public so I'd need some e-mail or other way to send it.
I'm available at marc.gravell at gmail.com, or another way that often works is inviting @mgravell to a private github repo
<PackageReference Include="Google.Protobuf" Version="3.22.0" />
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.54.0" />
<PackageReference Include="Grpc.Tools" Version="2.54.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="protobuf-net.Grpc" Version="1.1.1" />
if i add the package as below,it occur the error that i given
<PackageReference Include="protobuf-net.Grpc.AspNetCore.Reflection" Version="1.1.1" />
<PackageReference Include="System.ServiceModel.Primitives" Version="6.0.0" />
Is there any conflict ?
I'm available at marc.gravell at gmail.com, or another way that often works is inviting @mgravell to a private github repo
You got mail. And because I forgot to mention it in the mail:
MonthDto
(now wrapped in UpdateMonthPlanRequest
)MonthPlanExistsResponse
if i add the package as below,it occur the error that i given
I have the System.ServiceModel.Primitives
because it is required for OperationContract
, but I do not use protobuf-net.Grpc.AspNetCore.Reflection
.
I'm available at marc.gravell at gmail.com, or another way that often works is inviting @mgravell to a private github repo
You got mail. And because I forgot to mention it in the mail:
- The object from the SO issue was
MonthDto
(now wrapped inUpdateMonthPlanRequest
)- The object which leads to the marshaller error is
MonthPlanExistsResponse
if i add the package as below,it occur the error that i given
I have the
System.ServiceModel.Primitives
because it is required forOperationContract
, but I do not useprotobuf-net.Grpc.AspNetCore.Reflection
.
hello, have you find the problem?
If I had an update for you: I would have replied already. I haven't even had chance to look yet. Please be realistic about your expectations and demands here - this isn't paid commercial support; this is somebody giving up their free time to try to help strangers. I spent my weekend with my family. This is not my paid day job, and you're not a paying customer. Please don't pester people who are helping you on those terms! I'll look as soon as I can, but: don't nag - that just sucks the life and joy out of OSS.
If I had an update for you: I would have replied already. I haven't even had chance to look yet. Please be realistic about your expectations and demands here - this isn't paid commercial support; this is somebody giving up their free time to try to help strangers. I spent my weekend with my family. This is not my paid day job, and you're not a paying customer. Please don't pester people who are helping you on those terms! I'll look as soon as I can, but: don't nag - that just sucks the life and joy out of OSS.
i'm sorry to disturb you, i neglect the time zone (it is workday in my zone).
I had the issue like this once. For me the reason was in my grpc model. I had a property which is an enum that was inside the library (nuget), and the library was not directly (implicitly) added as a dependency to the assembly where I had my grpc model. Hope this can help someone.
Is there any further Investigation?
(1).if only it as client , it work well.
(2).now, it as client and server, and add grpc reflection
....
now .i ocur the error : ---> System.TypeInitializationException: The type initializer for 'DefaultProxyCache`1' threw an exception. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: No marshaller available for Xchain.Share.Serv.Orders.Orders.OrderDto at ProtoBuf.Grpc.Internal.MarshallerCache.g__Throw|50[T]() in //src/protobuf-net.Grpc/Internal/MarshallerCache.cs:line 39