The type or namespace name 'Forms' does not exist in the namespace 'System.Windows'

7.6k views Asked by At

I need to select json file.

public void LoadChartData()
{
   var ofDialog = new System.Windows.Forms.OpenFileDialog { Filter = @"json (*.json)|*.json" };
   if (ofDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
   { }
}

Unfortunately compilation of this code returns error (twice, for each System.Windows.Forms ):

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

How to handle with this error?

1

There are 1 answers

0
Patrick Hofman On BEST ANSWER

Include the System.Windows.Forms assembly in your project (as the error message suggested).

Go to your Solution Explorer, right click your project. Then click Add Reference. Choose System.Windows.Forms and hit OK.