分享方式:


嚴重錯誤 C1191

'dll' 只能在全域範圍匯入

將 mscorlib.dll 匯入至使用 /clr 程式設計之程式的指令不能出現在命名空間或函式中,但必須出現在全域範圍中。

下列範例會產生 C1191:

// C1191.cpp
// compile with: /clr
namespace sample {
   #using <mscorlib.dll>   // C1191 not at global scope
}

可能的解決方式:

// C1191b.cpp
// compile with: /clr /c
#using <mscorlib.dll>
namespace sample {}