Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/321.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# CSScript脚本与计时器一起出现错误_C#_.net - Fatal编程技术网

C# CSScript脚本与计时器一起出现错误

C# CSScript脚本与计时器一起出现错误,c#,.net,C#,.net,我有一个脚本,我想在其中使用计时器,但我收到一个错误“附加信息:{interactive}(11,5):错误CS0246:找不到类型或命名空间名称'Timer'。是否缺少using指令或程序集引用?” 我的主机应用程序是一个控制台应用程序,但我已在引用中包含System.Windows.Forms dll 这是代码。为什么我会得到这个错误 using System; using System.Windows.Forms; class Script : GameScript { public i

我有一个脚本,我想在其中使用计时器,但我收到一个错误“附加信息:{interactive}(11,5):错误CS0246:找不到类型或命名空间名称'Timer'。是否缺少using指令或程序集引用?”

我的主机应用程序是一个控制台应用程序,但我已在引用中包含System.Windows.Forms dll

这是代码。为什么我会得到这个错误

using System;
using System.Windows.Forms;

class Script : GameScript
{
public int Interval = 5000;
public bool StartOnLoad = true;

public event EventHandler OnTick;

Timer tmrTimer;
}

我在使用CSScript时遇到了类似的问题。 似乎在脚本中添加引用和包含using语句是不够的。 如果应用程序未使用引用程序集中的任何对象,则该程序集似乎被忽略且未包含在已编译的应用程序中,并且脚本无法看到它


尝试在承载脚本的应用程序中创建计时器。

尝试使用System.Timers添加
其他信息:{interactive}(11,5):错误CS0246:找不到类型或命名空间名称
Timer'。是否缺少using指令或程序集引用?{interactive}(37,49):错误CS0246:找不到类型或命名空间名称
ElapsedEventArgs'。是否缺少using指令或程序集引用?是否确实在引用中包含System.Windows.Forms dll?