C# 找不到 System.Windows 程序集
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/825743/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can not find System.Windows Assembly
提问by
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
错误 1 在未引用的程序集中定义了类型“System.Windows.Point”。您必须添加对程序集“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.
我们在无法找到 System.Windows 程序集的单元测试项目中遇到此错误,但我们的主项目可以找到该程序集并正常运行。
Does anyone have any input or advice on where or how we can reference System.Windows to fix this problem?
有没有人对我们在哪里或如何引用 System.Windows 来解决这个问题有任何意见或建议?
回答by Nick Berardi
Right click on your "References" folder and click "Add Reference" and then select System.Windows under the .NET tab.
右键单击“引用”文件夹并单击“添加引用”,然后在 .NET 选项卡下选择 System.Windows。
回答by Jon Skeet
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
- 右键单击项目
- 选择“添加参考”
- 选择左侧的.NET选项卡,在程序集列表中找到“System.Windows”
- 双击“System.Windows”,将添加程序集引用
回答by lc.
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...
您必须添加对项目的引用。如果您使用的是 Visual Studio,请在解决方案资源管理器中右键单击该项目,然后选择添加引用...
回答by lc.
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!
我们发现我们必须进入 Silverlight 文件夹并找到 System.Windows.dll,现在一切都很好,感谢您的帮助!
回答by Mike Graham
well, it was actually system.windows.presentation in my wpf app...
好吧,它实际上是我的 wpf 应用程序中的 system.windows.presentation ...
回答by dmertl
If you don't have System.Windows in your .NET references, try WindowsBase. That fixed my reference to System.Windows.Point in VS 2008.
如果您的 .NET 引用中没有 System.Windows,请尝试 WindowsBase。这修复了我在 VS 2008 中对 System.Windows.Point 的引用。
回答by Echilon
You'll also run into this error if you use the Portable Library Toolsas it's not supported.
如果您使用不支持的便携式库工具,您也会遇到此错误。
回答by Mehdi LAMRANI
In my case there was no System.Windows reference available to pick up.
I had to include a reference to WindowsBase
就我而言,没有可供选择的 System.Windows 参考。
我必须包含对WindowsBase的引用
回答by Jan
If you are using .NET Framework 2.0, referencing
如果您使用的是 .NET Framework 2.0,请参考
System.Windows.Forms
系统.Windows.Forms
(and using the namespace with the identical name) will do the job too
(并使用具有相同名称的命名空间)也可以完成这项工作
回答by Mister Cook
I had the same problem, however it was caused because we are using a Portable Class library and only occurred on certain PC installations.
我遇到了同样的问题,但是这是因为我们使用的是可移植类库,并且只发生在某些 PC 安装上。
I found the issue to be fixed on these installation with:
我发现问题可以通过以下安装解决:
http://www.microsoft.com/en-us/download/details.aspx?id=3556
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.
由于此修复程序包含在 VS2010 和 Windows 更新中,因此它只会出现在某些 PC 上。