DebugInfoGenerator.CreatePdbGenerator()該 API 從 .NET 5 開始被標記為過時。 使用此 API 會在編譯時產生警告SYSLIB0008,執行時拋出 。PlatformNotSupportedException
隱藏警告
如果您必須使用過時的 API,您可以在程式碼或專案檔中隱藏警告。
若要僅抑制單一違規,請將預處理器指示詞新增至來源檔案以停用,然後重新啟用警告。
// Disable the warning.
#pragma warning disable SYSLIB0008
// Code that uses obsolete API.
// ...
// Re-enable the warning.
#pragma warning restore SYSLIB0008
若要隱藏 SYSLIB0008 專案中的所有警告,請將屬性新增至 <NoWarn> 專案檔。
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
...
<NoWarn>$(NoWarn);SYSLIB0008</NoWarn>
</PropertyGroup>
</Project>
如需詳細資訊,請參閱隱藏警告。