33

This is the error we get:

Error 1 The type 'System.Windows.Point' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'. C:\PacMan\PacMan\PacMan\PacManTests\UnitTest1.cs 65 13 PacManTests

We get this error in our unit test project which cant find the System.Windows Assembly but our main project can find the assembly and run it fine.

Does anyone have any input or advice on where or how we can reference System.Windows to fix this problem?

McGarnagle
  • 101,349
  • 31
  • 229
  • 260
  • 3
    Hopefully you fixed this, since it's two years later!! I had to reference both PresentationFramework and WindowsBase to successfully create a System.Windows.Application in a testing project assembly. Go figure... – Berryl May 15 '11 at 00:50
  • 1
    WindowsBase did the trick for my NUnit test project. No WPF is referenced. Thanks. – J Pollack Feb 27 '12 at 16:00

15 Answers15

43

In my case there was no System.Windows reference available to pick up.
I had to include a reference to WindowsBase

Mehdi LAMRANI
  • 11,289
  • 14
  • 88
  • 130
22

Add the assembly reference as you'd add any other framework assembly reference:

  • Right-click on the project
  • Select "Add reference"
  • Select the .NET tab on the left, and find "System.Windows" in the list of assemblies
  • Double-click on "System.Windows" and the assembly reference will be added
Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • 3
    `System.Windows` does not appear in my list. Is it not available in .NET 4 Client Profile? – jocull Sep 14 '12 at 18:19
  • @jocull: It is according to MSDN, e.g. http://msdn.microsoft.com/en-us/library/system.windows.window.aspx – Jon Skeet Sep 15 '12 at 06:08
  • 8
    That would'nt help much. I had the same problem rihgt now - and there isn't any System.Windows (usng .net 4.5). In this case we needed to add "WindowsBase" – Offler Dec 17 '12 at 07:30
  • @Offler: Yes, I'm not sure what I was thinking of in this answer. Will edit. – Jon Skeet Dec 17 '12 at 07:47
  • 1
    @Offler: Actually, no, looking back - it *was* appropriate, because the question was about Silverlight (I think; it's odd that it's tagged WPF as well). On Silverlight it *is* System.Windows.dll - see http://msdn.microsoft.com/en-us/library/system.windows.window(v=vs.95).aspx. Otherwise the error doesn't make much sense. – Jon Skeet Dec 17 '12 at 07:49
  • 3
    Adding PresentationFramework.dll,PresentationCore and WindowsBase did the trick for me,I couldnt find a System.Windows in .NET 3.5. – ZoomIn Apr 16 '14 at 11:52
  • @ZoomIn: Well no, as noted in comments, System.Windows is the assembly for Silverlight - presumably you have a WPF project rather than Silverlight. – Jon Skeet Apr 16 '14 at 12:46
  • @JonSkeet Yes sir! Mine is a WPF project. – ZoomIn Apr 16 '14 at 13:16
  • Oh, I see now! System.Windows.Point is defined in two different assemblies.... I have a sick feeling that I've been adding Silverlight references to all my class libraries. I'm guessing he tagged it as WPF in accidental confusion with MVVM...? – C. Tewalt Feb 16 '16 at 16:22
  • @JonSkeet it was most definitely appropriate, it can be found in the silverlight installation. In my case that is: `C:\Program Files (x86)\Microsoft Silverlight\5.1.50906.0\System.Windows.dll` – Mafii Jan 05 '18 at 15:25
9

Add System.Windows assembly reference:

  • Right-click on the project
  • Select "Add reference"
  • Select the .NET tab on the left, and find "System.Windows" in the list of assemblies
  • Double-click on "System.Windows" to add it

If this does not solve the issue try Adding PresentationFramework, PresentationCore and WindowsBase assemblies (.NET 3.5)

edgarmtze
  • 24,683
  • 80
  • 235
  • 386
5

I had this occur on a machine with VS 2010 once before. For some reason, the System.Windows assembly was not found in the .NET tab of Add Reference window. Very strange.

In this case, you will just have to go to the Browse tab and navigate to:

C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Windows\

Once there, select the proper version subfolder (should look something like... v4.0_4.0.0.0__b03f5f7f11d50a3a) and then choose the System.Windows.dll there.

Derek W
  • 9,708
  • 5
  • 58
  • 67
5

We found it we had to go into the Silverlight folder and found the System.Windows.dll and now all is good thanks for the help though!

  • I had the same problem - strangely it was just ReSharper flagging the error though my project compiled correctly, and it was in a server-side class library, not even a SL library. – Craig Shearer Aug 13 '09 at 01:22
3

I've found the needed WindowsBase.dll in

C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0

Andrew
  • 31
  • 4
3

Right click on your "References" folder and click "Add Reference" and then select System.Windows under the .NET tab.

Nick Berardi
  • 54,393
  • 15
  • 113
  • 135
  • 6
    We have tried that there is no System.Windows under the .NET tab when we click on the references to add a reference. –  May 05 '09 at 16:32
  • That's very strange. What version of .NET do you have installed? – Jon Skeet May 05 '09 at 16:45
2

well, it was actually system.windows.presentation in my wpf app...

Mike Graham
  • 125
  • 1
  • 1
  • system.windows.presentation is an entirely different dll and does not represent the dll that is in question – gprasant Aug 31 '11 at 07:17
  • Mentioned assembly is System.Windows, not system.windows.presentation – pylover Dec 31 '11 at 07:35
  • 2
    This actually solved my problem, thanks! System.Windows is in the PresentationFramework.dll Check this: http://msdn.microsoft.com/en-us/library/system.windows.window.aspx – tesla May 11 '12 at 08:01
2

If you are using .NET Framework 2.0, referencing

System.Windows.Forms

(and using the namespace with the identical name) will do the job too

Jan
  • 141
  • 2
  • 7
2

I had the same problem, however it was caused because we are using a Portable Class library and only occurred on certain PC installations.

I found the issue to be fixed on these installation with:

http://www.microsoft.com/en-us/download/details.aspx?id=3556

As this fix is included with VS2010 and Windows Update it would only occur on certain PCs.

Mister Cook
  • 1,552
  • 1
  • 13
  • 26
2

Add the same references in your test project as you see as references in the project you are testing.

I got something like this and added:

PresentationCore PresentationFramework WindowsBase

Now it seems to stay quiet.

JaJa
  • 411
  • 2
  • 13
2

If you don't have System.Windows in your .NET references, try WindowsBase. That fixed my reference to System.Windows.Point in VS 2008.

dmertl
  • 805
  • 8
  • 13
1

You'll also run into this error if you use the Portable Library Tools as it's not supported.

Echilon
  • 10,064
  • 33
  • 131
  • 217
1

You have to add the reference to the project. If you're using Visual Studio, right-click the project in the Solution Explorer, and choose Add Reference...

lc.
  • 113,939
  • 20
  • 158
  • 187
0

Try with adding PresentationCore.dll After it you can use System.Windows namespace

miciry89
  • 196
  • 1
  • 5