5

Following every guide everywhere:

  • Step 1:

enter image description here

  • Step 2: it works! Huzzah! Except that it doesn't. Instead I get yellow triangles:

enter image description here

This project is tiny for now because I only just started. The guides about yellow triangles talk about conflicts which can't be the case here. I have next to nothing imported or used yet:

enter image description here

not_a_generic_user
  • 1,906
  • 2
  • 19
  • 34
  • Just noticed this warning in the console area: Severity Code Description Project File Line Suppression State Warning MSB3290 Failed to create the wrapper assembly for type library "{215d64d2-031c-33c7-96e3-61794cd1ee61}". Type library 'System_Windows_Forms' was exported from a CLR assembly and cannot be re-imported as a CLR assembly. – not_a_generic_user Apr 29 '22 at 13:25

1 Answers1

20

Apparently this is due to using .Net Core and Microsoft couldn't anticipate that people would want to use forms in the new normal...

I found this: How to use System.Windows.Forms in .NET Core class library

This is what worked:

  • Removed reference/dependancy entirely
  • Right-click project, Unload
  • Right-click project, Edit project file
  • Add the following:
    <PropertyGroup>
        <TargetFramework>net6.0-windows</TargetFramework>
        <UseWPF>true</UseWPF>
        <UseWindowsForms>true</UseWindowsForms>
    </PropertyGroup>
  • Reload project file
  • Add "using system.windows.forms" to the top.
not_a_generic_user
  • 1,906
  • 2
  • 19
  • 34
  • Hi not_a_generic_user, glad to know you've found the solution to resolve this issue! Please consider accepting it as an answer to change its status to Answered. It will also help others to solve a similar issue. See [can I answer my own question..](https://stackoverflow.com/help/self-answer), Just a reminder :) – Jiale Xue - MSFT May 02 '22 at 02:36
  • This worked for me, thanks! C# WPF .NET 6.0 – lentz Sep 07 '22 at 19:10