2011-01-23 77 views
-1

我寫了這段代碼,但是當我運行它時,調試器提示我「DragDrop註冊沒有成功。」在FormAdver.show();線,我該如何解決它?問題形式顯示

public void ResiveFunc(string FuncResive) 
    { 


     string FuncName = ""; 
     string FuncValue = ""; 
     for (int i = 0; i <= 2; i++) 
     { 
      FuncName += FuncResive[i]; 
     } 
     for (int j = 4; j <= FuncResive.Length - 1; j++) 
     { 
      FuncValue += FuncResive[j]; 
     } 
     MessageBox.Show(FuncName); 
     MessageBox.Show(FuncValue); 
     if (FuncName == "TAB") 
     { 
      Form1 mainForm = new Form1(); 
      frmAddver formAddver = new frmAddver(); 
      formAddver.Show(); 
      mainForm.AdverFilter(FuncValue); 

     } 
    } 
+0

可能重複(http://stackoverflow.com/questions/4769915/problem-with-multi-threaded-invocation) – 2011-01-23 12:45:27

回答

0

你有兩個選擇

  1. 確保AllowDropfalse上的控件在FormAdver

  2. 確保單元狀態設置爲STA。通過Thread.CurrentThread.ApartmentState = ApartmentState.STA或使用[STAThread]屬性。

[問題的多線程/調用:(]的