注意:這類似于
uj5u.com熱心網友回復:
您使用哪個 TargetFramework?如果您使用一些經典框架,net48一切都應該可以正常作業。
對于現代目標框架(如net6.0),不可能“僅參考”
System.Windows.Forms。例如,如果您添加對專案檔案的普通參考,例如
<ItemGroup>
<Reference Include="System.Windows.Forms" />
</ItemGroup>
該專案將無法正確構建。MSBuild 產生下一個警告:
Microsoft.Common.CurrentVersion.targets(2301, 5):
[MSB3245] Could not resolve this reference. Could not locate the assembly "System.Windows.Forms".
Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
如果您想在現代控制臺應用程式中使用 Windows 表單,則必須將這些行添加到專案檔案中,而不是添加單個參考:
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/487101.html
上一篇:非靜態欄位、方法或屬性“Program.c8y_Event_MSG”需要物件參考[deserializeJSON]
