小编Lui*_*ada的帖子

为什么我得到这个NullReferenceException C#

我一直在使用一些代码来处理通过Active目录查询来管理连接用户和设备的应用程序.

然后我得到这个错误"NullReferenceException未处理"大约一个星期,使用代码这是唯一阻止应用程序的东西.

这是我使用的背景代码:

private void backgroundWorker2_Dowork(object sender, DoWorkEventArgs e)
{
    try
    {
        e.Result = "";

        int val = 6000;

        for (int a = 1; a <= val; a++)
        {
            counter.Text = Convert.ToString(a);
            if (txtWorkGroupName.Text == "") return;

            DataTable dt = new DataTable();
            dt.Clear();

            dt.Columns.Add(new DataColumn("ComputerName", typeof(String)));                        //0
            dt.Columns.Add(new DataColumn("IP", typeof(String)));            //1
            dt.Columns.Add(new DataColumn("MAC", typeof(String)));       //2
            dt.Columns.Add(new DataColumn("Descubierto", typeof(String)));       //3
            //int i = 0;

            try
            {
                // Datos del grupo WinNT://&&&&(Nombre del grupo de trabajo)
                DirectoryEntry DomainEntry = new DirectoryEntry("WinNT://" + …
Run Code Online (Sandbox Code Playgroud)

c# error-handling datagridview nullreferenceexception

3
推荐指数
1
解决办法
3236
查看次数