Can not find System.Windows Assembly

2019-02-05 18:04发布

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?

15条回答
干净又极端
2楼-- · 2019-02-05 19:00

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

查看更多
Fickle 薄情
3楼-- · 2019-02-05 19:00

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...

查看更多
4楼-- · 2019-02-05 19:03

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.

查看更多
再贱就再见
5楼-- · 2019-02-05 19:04

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
查看更多
别忘想泡老子
6楼-- · 2019-02-05 19:04

I've found the needed WindowsBase.dll in

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

查看更多
家丑人穷心不美
7楼-- · 2019-02-05 19:05

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

查看更多
登录 后发表回答