namespace name 'DispatcherTimer' could not be found
本文关键字:be found not could namespace DispatcherTimer name | 更新日期: 2023-09-27 18:08:22
我试图使用调度定时器,但我的c#应用程序找不到命名空间。这是错误:
类型或命名空间名称'DispatcherTimer'找不到(您是否缺少using指令或程序集引用?)
下面是我使用的:
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Globalization;
using System.Text;
using System.Threading;
using System.Timers;
using System.Windows.Forms;
代码如下:
DispatcherTimer timer1 = new DispatcherTimer();
DispatcherTimer
不是一个命名空间-它是System.Windows.Threading
命名空间和WindowsBase
集合中的一个类。所以你需要
using System.Windows.Threading;
一般来说,搜索缺失的类型名称和"MSDN"就足以找到在哪里可以找到类型。
Dispatcher类在WindowsBase.dll中。你必须在你的项目中添加引用来使用"using System.Windows.Threading;"& lt;>
添加
using System.Windows.Threading;
MSDN
不在System. windows . threading命名空间中,也不在System. threading命名空间中。线程名称空间?
http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatchertimer.aspx你必须在你的引用中添加WindowsBase,这样你才能使用System.Windows.Threading.