Reputation: 21
I am having a ATL project where in I have to use System namespace to set environment variables. I tried:
#using <mscorlib.dll>
using namespace System;
in my dllmain.cpp file.
While building, I got:
fatal error C1190: managed targeted code requires a '/clr' option even after adding /clr option project->properties->common language runtime support.
If I remove #using mscorlib.dll, I am getting:
error C2871: 'System' : a namespace with this name does not exist
How can I use this namespace in my ATL project?
Upvotes: 1
Views: 4587
Reputation: 1888
See this link from MSDN.
I quote the answer here:
As you are including a reference to mscorlib.dll you need to let the compiler know that you are targetting the .NET Runtime. The compiler switch that controls this is /clr - hence the error message you are seeing. To enable this option from the project system in the Solution Explorer pane right-click on your project, select Configuration Properties.General and then select "Common Language Runtime support" and from the drop-down list select "Common Language Runtime Support (/clr)".
In C++ identifiers are case-sensitive: I suspect that the name should be System::Console.
Upvotes: 1