共用方式為


連結器工具警告 LNK4227

中繼資料作業警告 ( HRESULT ) : warning_message

連結器在合併時偵測到中繼資料差異:

  • 目前建置元件的一或多個參考元件。

  • 編譯中的一或多個原始程式碼檔案。

例如,如果您有兩個具有相同名稱但參數資訊不同宣告的全域函式,可能會造成LNK4227 。也就是說,宣告在所有編譯和中都不一致。 在每個 .obj 檔案上使用 ildasm.exe /TEXT /METADATA object_file ,以查看類型的差異。

LNK4227也可用來報告源自另一個工具的問題。 搜尋警告訊息以取得詳細資訊。

中繼資料問題必須修正,才能解決警告。

範例

當參考的元件簽署方式與參考元件的元件不同時,會產生LNK4227。

下列範例會產生LNK4227:

// LNK4227.cpp
// compile with: /clr
using namespace System::Reflection;

[assembly:AssemblyDelaySignAttribute(false)];

int main() {}

然後

// LNK4227b.cpp
// compile with: /clr LNK4227.cpp /FeLNK4227b.exe
using namespace System::Reflection;
using namespace System::Runtime::CompilerServices;

[assembly:AssemblyDelaySignAttribute(true)];
// Try the following line instead
// [assembly:AssemblyDelaySignAttribute(false)];

ref class MyClass
{
};

當錯誤格式的版本號碼傳遞至元件屬性時,也可以產生LNK4227。 '*' 標記法是 特定的 AssemblyVersionAttribute 。 若要解決此警告,請只使用 版本屬性中的數位,而非 AssemblyVersionAttribute

下列範例會產生LNK4227:

// LNK4227e.cpp
// compile with: /clr /LD /W1
using namespace System::Reflection;
[assembly:AssemblyVersionAttribute("2.3.*")];   // OK
[assembly:AssemblyFileVersionAttribute("2.3.*")];   // LNK4227
// try the following line instead
// [assembly:AssemblyFileVersionAttribute("2.3")];