Search code examples
c#.net.net-core.net-standardeasynetq

How to solve CS0246 The type or namespace name 'TypeNameSerializer' could not be found (are you missing a using directive or an assembly reference?


I have a .net framework class library project which is absolutely working fine with the .net framework projects, Now I need to refer it in .net core application also. so I am trying to create a new .net standard project and copied all the .cs files to this project from the existing project. and started fixing the compilation errors. I have fixed many but still getting a few.

_rabbitBus = RabbitHutch.CreateBus(
    ConfigurationManager.ConnectionStrings[queueName].ConnectionString,
    serviceRegister => serviceRegister.Register<ISerializer>(
        serviceProvider => new JsonSerializer(new TypeNameSerializer())
    )
);

I am getting the below error with the code mentioned above.

CS0246 The type or namespace name 'TypeNameSerializer' could not be found (are you missing a using directive or an assembly reference?)

So How to solve this issue?

Note: I have fixed the compilation error b using this code new JsonSerializer(new Newtonsoft.Json.JsonSerializerSettings()) , but I don't know whether its correct way or not, So please guide me how to solve this issue.


Solution

  • Looks like different versions of EasyNetQ are being used in .NET Framework and .NET Core.

    The latest version of EasyNetQ does not have any class with name TypeNameSerializer that's why you are getting this error.

    Also class JsonSerializer in latest version of EasyNetQ does no have a constructor which accepts TypeNameSerializer as a parameter.

    You can refer to Git Repo of EasyNetQ and also the Source Code of JsonSerializer class.

    You need to use the same version of EasyNetQ in .NET Core as it is being used in .NET Framework project in order to use TypeNameSerializer.