共用方式為


編譯器錯誤 C3808

'type' :具有 ComImport 屬性的類別無法定義成員 'member',只允許抽象或 dllimport 函式

備註

衍生自 ComImportAttribute 的類型無法定義 成員

Visual Studio 2015 中已淘汰 /clr:pure/clr:safe 編譯程序選項,且 Visual Studio 2017 不支援。

範例

下列範例會產生 C3808。

// C3808.cpp
// compile with: /c /clr:pure user32.lib
using namespace System::Runtime::InteropServices;

[System::Runtime::InteropServices::ComImportAttribute()]
ref struct S1 {
   int f() {}   // C3808
   virtual int g() abstract;   // OK

   [DllImport("msvcrt.dll")]
   int printf(System::String ^, int i);   // OK
};