Avviso del compilatore (livello 1) C4397

DefaultCharSetAttribute viene ignorato

DefaultCharSetAttribute viene ignorato dal compilatore Microsoft C++. Per specificare un set di caratteri per la DLL, usare l'opzione CharSet di DllImport. Per altre informazioni, vedere Uso dell'interoperabilità C++ (PInvoke implicito).For more information, see Using C++ Interop (Implicit PInvoke).

Esempio

L'esempio seguente genera l'errore C4397.

// C4397.cpp
// compile with: /W1 /c /clr
using namespace System;
using namespace System::Runtime::InteropServices;

[module:DefaultCharSetAttribute(CharSet::Unicode)];   // C4397

[DllImport("kernel32", EntryPoint="CloseHandle", CharSet=CharSet::Unicode)]   // OK
extern "C" bool ImportDefault(IntPtr hObject);

public ref class MySettingVC {
public:
   void method() {
      ImportDefault(IntPtr::Zero);
   }
};

[StructLayout(LayoutKind::Explicit)]
public ref struct StructDefault1{};

public ref class ClassDefault1{};