Reputation: 4260
I have followed this article to start using MessagePack in my asp.net core 3.1 application but it's not working due to the following error message:
Severity Code Description Project File Line Suppression State Error CS1503 Argument 1: cannot convert from 'MessagePack.Resolvers.ContractlessStandardResolver' to 'MessagePack.MessagePackSerializerOptions' Gateway C:\Developments\POC\Gateway\Startup.cs 33 Active
What is another alternative or solution to fix this compile problem?
Upvotes: 0
Views: 1354
Reputation: 6881
As @Michael said, what is needed behind MessagePackOutputFormatter
is the MessagePackSerializerOptions
type, and the current error occurs because the type is ContractlessStandardResolver, which is not consistent.
Therefore, you only need to modify the code as follows:
services.AddMvc().AddMvcOptions(option =>
{
option.OutputFormatters.Clear();
option.OutputFormatters.Add(new MessagePackOutputFormatter(ContractlessStandardResolver.Options));
option.InputFormatters.Clear();
option.InputFormatters.Add(new MessagePackInputFormatter(ContractlessStandardResolver.Options));
})
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
Upvotes: 1