3

My code starts off like this:

#include "stdafx.h"
#include <string>
#using <mscorlib.dll>
#using <System.Data.dll>
#using <System.dll>

using namespace System;
using namespace System::Data::OleDb;

but ends up with the compile error "#using" requires C++/CLI mode

I had this problem initially and managed to solve this through following this post IntelliSense: "#using" requires C++/CLI to be enabled. Updated VS2017 to ver 15.3.0 yesterday and now it is broken again. Project Properties are as follows:

enter image description here

Any assistance would be greatly appreciated. P.

Paul
  • 813
  • 11
  • 27
  • Are you sure that the file specific settings have the same settings for the CLR support. Remember, that you can set and change properties for each file separate. – xMRi Aug 15 '17 at 09:55
  • @xMRi I have checked this and there is no issue as far as I can tell. – Paul Aug 15 '17 at 10:14

2 Answers2

2

I came across the same issue and figured out that the settings(Common Language Runtime Support) were set only for Release configuration. I suggest you to check for all the configurations in your solutions Release/Debug etc.. and set the CLR support option and it should work as expected.

0

You can also control this setting from within the code by putting this in your files

#pragma managed

First I would search your code to be sure this #pragma isn't being used to turn OFF managed building somewhere earlier (in some #include file, perhaps?). Then try putting it in this file>

I'm not sure if this will solve your problem but it should at least eliminate the worry that the file is not being build properly. And perhaps the error message might change to give you a better idea what the problem is

https://msdn.microsoft.com/en-us/library/0adb9zxe.aspx?f=255&MSPPError=-2147217396

C++ CLI Correct way to use #pragma managed / unmanaged

Joe
  • 5,394
  • 3
  • 23
  • 54
  • Unfortunately not. I have restarted, created new projects etc. No joy. I have raised this with MS. – Paul Aug 15 '17 at 16:53