5

I am getting the error:

the type 'system.windows.controls.control' is defined in an assembly that is not referenced".

How to add a reference to assembly?

rhughes
  • 9,257
  • 11
  • 59
  • 87
voraD
  • 515
  • 2
  • 5
  • 7

5 Answers5

7

For completeness, and in the unlikely event that you are not using Visual Studio (which you didn't specify), you can add assembly references to csc using the /r: compiler option. Likewise with the <References> element of the <Csc> task in msbuild.

harpo
  • 41,820
  • 13
  • 96
  • 131
4

Solution Explorer > References (Rigth-click) > Add Reference

Search for System.Windows and add it to your references.

Also see the documentation: How to: Add or Remove References By Using the Add Reference Dialog Box

Selman Genç
  • 100,147
  • 13
  • 119
  • 184
2

See:

In Solution Explorer, double-click the My Project node for the project.

In the Project Designer, click the References tab.

Click the Add button to open the Add Reference dialog box.

In the Add Reference dialog box, select the tab indicating the type of component you want to reference.

Select the components you want to reference, and then click OK. enter image description here

1

To reference an assembly you would right-click the References node in the Solution Explorer and select Add.

That said, I have to question why you would be trying to use a WPF control in a project that doesn't already have the appropriate reference(s). Can you explain why because you might be trying to accomplish something in the wrong way?

jmcilhinney
  • 50,448
  • 5
  • 26
  • 46
0

In visual studio, on solution explorer, right click on references and then click on Add reference, on the right panel you can select references.

Behrad Farsi
  • 1,110
  • 13
  • 25