visual studio, error in creating x64 dll and using in c# console app

  c++, dll, visual-studio, visual-studio-2019

I have successfully created a x86 dll project and referenced that in a c# console app (visual studio 2019). However, when I compile the dll project to a x64 target and try to add the output dll to the "add project reference" window in the console app it gives "The reference is invalid or unsupported" error. I have changed the following settings in the console app but it does not work:

Project properties->Build->platform target to x64

configuration manager->active solution platform to x64 (using New)

anyone knows what the problem is?

Source: Windows Questions C++