In the header file, Encrypt.h, I have the following:
#pragma once
using namespace System;
namespace NSpace
{
namespace Encryption
{
[System::Runtime::CompilerServices::Extension]
public ref class EncryptionExtensions abstract sealed
{
public:
[System::Runtime::CompilerServices::Extension]
static String^ ExtractEncrypt(String^ value, int length)
{
return value->Substring(0, length);
}
};
}
}
In a VS 2015 project that I set up for testing, this builds without errors or warnings. In my original project, ported from VS 2010, above will not build: error C2337: 'Extension' : attribute not found error C2337: 'Extension' : attribute not found error C2337: 'Extension' : attribute not found error C2337: 'Extension' : attribute not found
Note two errors for each offending use of [Extension].
The project is C++/CLI (Properties->General->Common Language Runtime Support is set (/clr)). The Platform Toolset is Windows7.1SDK - the test project started out with "Visual Studio 2015 (v140)", but I changed it to emulate the failing project, and it didn't make any difference in the test project, it still builds.
The project Properties->C/C++->General->Common Language Runtime Support is also set (/clr).
The original build environment is VS 2010, version 10.0.40219.1 SP1Rel. The original and ported projects are both targeting .Net 4.0 (for C# projects).
Any ideas why this won't build (in the original project)?