Set Common Language RunTime Support to be "Common Language RunTime Support (/clr)" in 2 places in your project properties :
For Visual Studio before 2019:
Configuration Properties -> General Configuration Properties -> C/C++ -> General For Visual Studio 2019:
Configuration Properties -> Advanced -> C++/CLI Properties Configuration Properties -> C/C++ -> General