3

While I'm using System.Windows.Forms in my project

This error shows up

The type or namespace name 'Forms' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?)

Refer to this question

I've added the following code in my .csproj. But this doesn't solve the error.

<Reference Include="System.Windows.Forms" Version="2.0.0.0"/>

Refer to this question , I'm using visual studio code and this looks like doesn't help much in my situation. Is there is any way to add the reference to solve the problem? Thanks for spending your time on my question!!

JJ___
  • 187
  • 2
  • 4
  • 14
  • 6
    As far as I know Visual Studio Code doesn't support `Windows.Forms`, because of it's platform independency. – waka Jan 29 '18 at 07:46
  • Actually I'm doing minimize my console application to system tray on my project, is that mean there is no way to do by using Visual Studio Code? – JJ___ Jan 29 '18 at 07:52
  • I have no experience with Visual Studio Code, but all OS'ses should have something similar to a sys tray. However, what do you need `Windows.Forms` for in a console application? – waka Jan 29 '18 at 07:54
  • It is something like [this](https://social.msdn.microsoft.com/Forums/vstudio/en-US/d7255ec6-ad0b-47e8-8beb-51afefbf1959/running-console-application-in-system-tray?forum=csharpgeneral). What I want to do is to run my .exe file on window startup and minimize the console in sys tray instead of poping up on window – JJ___ Jan 29 '18 at 08:04

1 Answers1

2

Did you remember to add the reference thusly:

enter image description here

Because if you didn't that might very well be why, you need to right click on references, that is hightlighted in blue on the image. and then select "Add reference".

I did this, and I am able to create and display a form from a console app.

EDIT:

How to add assembly references in Visual Studio Code?

Please refer to this link for this visual-studio-code solution. I apoligize. However, the other solution applies just fine for visual studio :) So I am leaving it in :)

I does actually seem like that System.Windows.Forms is not supported for VS Code, due to a subset of Windows.Forms require some windows specific features.

For the full feature support, the recommended method is to install Visual Studio community.

I apoligize for the confusion. I should have checked first, if the library was even supported. I didn't.

https://code.visualstudio.com/docs/languages/csharp

The link at the bottom has a little FAQ section that tell you to install visual studio community, for full feature support.

Morten Bork
  • 1,413
  • 11
  • 23
  • You are showing Visual Studio. The OP is using VS Code. –  Jan 29 '18 at 15:17
  • @ShawnMelton you are absolutely correct, I have added a link to a fellow SO post, where the process is described for any system reference. Sorry about that. – Morten Bork Jan 29 '18 at 17:26
  • Thanks for your answer, but the link does not work for me as I have try using nuget to add the reference and it only shows me **System.Windows.Forms.Ribbon35** , this reference looks like is not the one I'm looking for. – JJ___ Jan 30 '18 at 01:34
  • @JJ__ did you install all re extensions in the guide in the link or only nuget? – Morten Bork Jan 30 '18 at 05:24
  • @MortenBork Yes I installed all the extensions in the guide. – JJ___ Jan 30 '18 at 05:30
  • Seems that @waka was correct -> there is no support for system.windows.forms. – Morten Bork Jan 30 '18 at 07:28