NET Core 5 RawRabbit序列化程序/依赖项注入问题



我有基于的微服务。NET核心2.2。我使用RawRabbit(2.0.0-beta9版本(作为服务总线。安装了以下软件包:

<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" />

这就是我的控制器的样子:

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}");
}

当代码尝试执行以下操作时,就会出现问题:

await _busClient.PublishAsync(model);

我得到的例外是:

找不到方法:"Void Newtonsoft。"。Json。JsonSerializer.set_TypeNameAssemblyFormat(System.Runtime.Serialization.Formatters.FormatterAssemblyStyle('.

它似乎与您的消息代理或发布无关(顺便说一句,如果您提到消息是否由您的消费者接收可能会更好(但是,您似乎在牛顿JSON中使用了TypeNameAssemblyFormat,根据这里的说法,它现在已经过时了。

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

您应该使用TypeNameAssemblyFormatHandling。另请参见此处

相关内容

  • 没有找到相关文章

最新更新