C# Getting System.IO.FileNotFound Exeception

178 Views Asked by At

I'm trying to create a program in C# that can manipulate the mouse cursor. I am getting a System.IO exception when I call the method in main and run the program.

I'm doing this in Visual Studio 2019. To run the method below, I am using System.Windows.Forms and System.Drawing. I have both referenced.

 public static void AutomateMouse()
 {
       int x = 500;
       int y = 500;
       Cursor.Position = new System.Drawing.Point(x, y);
       Console.WriteLine(Cursor.Position.ToString());
 }

The expected result of this method was printing of the cursor to the coordinates specified in the method. I get this exception, on the fifth line when I run the program:

System.IO.FileNotFoundException: 'Could not load file or assembly
 'System.Security.Permissions, 
Version=0.0.0.0, 
Culture=neutral, 
PublicKeyToken=cc7b13ffcd2ddd51'. 
The system cannot find the file specified.'
0

There are 0 best solutions below