简体   繁体   English

.NET Core 5 RawRabbit 序列化器/依赖注入问题

[英].NET Core 5 RawRabbit Serializer/Dependency Injection Issue

I have microservice based on .NET Core 2.2.我有基于 .NET Core 2.2 的微服务。 I am using RawRabbit (version 2.0.0-beta9) as the service bus.我使用 RawRabbit(版本 2.0.0-beta9)作为服务总线。 The following packages were installed with it:与它一起安装了以下软件包:

<PackageReference Include="RawRabbit" Version="2.0.0-beta9" />
<PackageReference Include="RawRabbit.DependencyInjection.ServiceCollection" Version="2.0.0-beta9" />
<PackageReference Include="RawRabbit.Operations.Publish" Version="2.0.0-beta9" />
<PackageReference Include="RawRabbit.Operations.Subscribe" Version="2.0.0-beta9" />

This is what my controller looks like:这是我的 controller 的样子:

 private readonly IBusClient _busClient;

//...constructor that inits the _busClient

[HttpPost("")]
public async Task<IActionResult> Post([FromBody] CreateActivity model)
{
    model.Id = Guid.NewGuid();
    await _busClient.PublishAsync(model); //Exception thrown here
    return Accepted($"Activities/{model.Name}");
}

The problem occurs when the code tries to do the following:当代码尝试执行以下操作时会出现问题:

await _busClient.PublishAsync(model);

The exception I get is:我得到的例外是:

Method not found: 'Void Newtonsoft.Json.JsonSerializer.set_TypeNameAssemblyFormat(System.Runtime.Serialization.Formatters.FormatterAssemblyStyle)'.找不到方法:'无效 Newtonsoft.Json.JsonSerializer.set_TypeNameAssemblyFormat(System.Runtime.Serialization.Formatters.FormatterAssemblyStyle)'。

Seems it's not related to your message broker or publish (by the way It could be better if you mentioned whether the message was received by your consumer or not) But seems somewhere you are using TypeNameAssemblyFormat in newton JSON which is obsolete now according here .似乎它与您的消息代理或发布无关(顺便说一下,如果您提到消息是否被您的消费者接收到可能会更好)但似乎您正在某处使用 Newton JSON 中的 TypeNameAssemblyFormat ,现在根据此处已过时。

[ObsoleteAttribute("TypeNameAssemblyFormat is obsolete. Use TypeNameAssemblyFormatHandling instead.")]
public FormatterAssemblyStyle TypeNameAssemblyFormat { get; set; }

You should use TypeNameAssemblyFormatHandling.您应该使用 TypeNameAssemblyFormatHandling。 Also see here也见这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM