I had the same problem when I tried to add a dll I just coded in C++ to my new C# project. Turned out I needed to set properties of the C++ project my dll is from:
Configuration Properties\General\Common Language Runtime Support:
/clr
Configuration Properties\C/C++\General\Common Language RunTime
Support: /clr
Because the C# project in which I wanted to use this dll was also set like that (had the same properties set to /clr
).