Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
392 views
in Technique[技术] by (71.8m points)

.net - Can't find System.Windows.Vector in C#

I'm making a Windows Forms application in Visual Studio 2010 Ultimate, but can't get the built-in Vector to work.

Microsoft says that there is a System.Windows.Vector in the .NET Framework 4:

Maybe I'm making some large mistake, but Visual Studio complains about trying to use Vector in any way, and it doesn't come up in the IntelliSense autocomplete:

The line Vector v = new Vector(20, 30); gives

Compile error Error 1 The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?)"

I tried including a using System.Windows at the top but that didn't solve the problem.

I went to References -> Add Reference to try to find something to add, but nothing was obvious.

The problem may be: Also listed with Vector in the System.Windows namespace, there are other classes like Rect or Application. I could use these as System.Drawing.Rectangle or System.Windows.Forms.Application, but none of these show up as part of some System.Windows namespace

I've tried different things for about 2 hours, and found this related post (but Vector is part of .NET 4, so their fix doesn't seem worthwhile?) and this possibly related post but I do have .NET Framework 4 installed.

Does anyone have an example of Vector? I know I could get a third party class, but I feel I'm missing something, and want to learn/have the solution posted for other people googling the same problem.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Add a reference to WindowsBase.
The Vector class is defined in the WindowsBase.dll assembly within the System.Windows namespace.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...