I'm following this tutorial cursor tutorial , but when i copy +paste the code in my c# desktop application and on building the app follwoing error is given

error CS0103: The name 'Mouse' does not exist in the current context

any idea on this error? I've search for the class "Mouse" and it is there in C# Mouse Class

5 Answers

Daniel Schlößer On Best Solutions

The mentioned System.Windows.Input namespace is part of Windows Presentation Foundation, not Windows Forms. Maybe you started with the wrong Visual Studio Project template?

Svexo On

Are u sure u did the following :

1: In the soulution explorer added the reference PresentationCore.dll (Under the tab COM)

2: Added "using System.Windows.Input;" at the top of the current file

Bridge On

There's a Mouse class in Microsoft.VisualBasic.Devices as well - I suspect they copied and pasted that bit of their code from their VB example on the same page.

DmitryG On

I believe in WinForms you can implement the same logic using the Cursor.Current instead of WPF-specific Mouse.OverrideCursor.


Chuck Savage On

The link you posted to the tutorial shows a WPF application, not a winforms.