首页 > 解决方案 > C# 获取 System.IO.FileNotFound 异常

问题描述

我正在尝试用 C# 创建一个可以操纵鼠标光标的程序。当我在 main 中调用该方法并运行程序时,我得到一个 System.IO 异常。

我在 Visual Studio 2019 中执行此操作。要运行以下方法,我正在使用System.Windows.FormsSystem.Drawing. 我都参考了。

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

此方法的预期结果是将光标打印到方法中指定的坐标。当我运行程序时,我在第五行得到了这个异常:

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

标签: c#visual-studiosystem.security

解决方案


推荐阅读