注意:这类似于https://stackoverflow.com/q/65920102/5784265,但这个问题从来没有得到一个有效的答案,我发现其他人有相同的问题,但没有解决办法。
当尝试添加对C#项目引用的引用时,添加->添加引用,对话框为空。
不过,就连官方的JetBrains文档也说要这样做。
因此,例如,我如何在控制台应用程序中添加对System.Windows.Forms的引用(默认情况下不包括该名称空间)?
添加引用对话框的图像:

发布于 2022-06-05 13:39:37
你用哪种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://stackoverflow.com/questions/72505804
复制相似问题