MSB3274:無法解析主要參考 'name',因為它是針對 'version' 架構建置的
完整錯誤類似下列文字:
The primary reference 'name' could not be resolved because it was built against the 'version' framework. This is a higher version than the currently targeted framework 'version'.
當參考的版本高於您目前建置的版本時,.NET Framework 專案中就會發生此錯誤。 請考慮以較新版本的 .NET Framework 為目標。 例如,如果您的專案以 .NET Framework 4.7.2 為目標,如果您參考 NuGet 套件或以 .NET Framework 4.8 為目標的另一個專案,您可能會看到此錯誤。
在 Visual Studio 中,檢查專案屬性頁中的目標 Framework。 請參閱 Framework 目標概觀。
在專案檔中,您可以設定目標架構,如下所示:
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
若要隱藏此錯誤,可設定下列 MSBuild 屬性:
<PropertyGroup>
<ResolveAssemblyReferenceIgnoreTargetFrameworkAttributeVersionMismatch>true</ResolveAssemblyReferenceIgnoreTargetFrameworkAttributeVersionMismatch>
</PropertyGroup>
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應