请看下面代码public class Remote
{
public getA()
{
return ((IA)Activator.GetObject(typeof(IA), "http://127.0.0.1:8080/IA.rem")));
}
}public class Form1:Form
{
Thread thr;
Lable lblMsg;

public Form1()
{
thr = Thread(new ThreadStart(MyInit));
} private void ChangedMessage(string Msg)
        {
            lblMsg.Text = Msg;
        }
        
public void MyInit()
{
this.Invoke(new Action<string>(this.ChangedMessage), "正在加载帐套......");

IA a = Remote.getA();
try
{
//用调试跟踪了一下,上面能够执行,当下面代码就不会执行,不知道为什么?
string[] booksName = a.GetAllBooksName();
....
}
catch (Exception e)
{
this.Invoke(new Action<string>(this.ChangedMessage), e.Message);
}
finally
{
a.Dispose();
}

....
}

//窗体第一次显示时触发该事件
private void LoginForm_Shown(object sender, EventArgs e)
        {
            thr.Start();
        }
}

解决方案 »

  1.   

    private void LoginForm_Shown(object sender, EventArgs e) 

           thr = Thread(new ThreadStart(MyInit)); 
           thr.Start(); 
    } 试试
      

  2.   

    1、thr = Thread(new ThreadStart(MyInit));
       thr.Start(); 2、多线种调试比较困难的,有时候程序会像挂掉一样,可以使用日志记录信息的方法调试~
      

  3.   

    private void LoginForm_Shown(object sender, EventArgs e)
    {
          thr = Thread(new ThreadStart(MyInit));
          thr.Start();
    }
    也是一样的错误