2016-12-20 13 views
-1

.NETコンソールアプリケーションがあり、newtonsoftライブラリに問題があります。スタートボタンをクリックしてVisual Studioでコンソールアプリケーションを起動しても問題ありません。すべてが良いです。私がobj /デバッグフォルダの下myprogram.exeという実行しようとするしかし、それはエラーを以下与える:System.IO.FileNotFoundException、Newtonsoft.Json .Net

"System.IO.FileNotFoundException: 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'file or compilation, or one of its dependencies. The system can not find the specified file.File Name: 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' Location: Barcode_Form.Cloud_Form.Check_Cloud(String username, String password)"

private void button_login_Click(object sender, EventArgs e) 
    { 
     label_response.Text = "Baglaniyor..."; 
     //Make buttons not clickable until the result of login trial 
     Button_status(false); 
     try { 
      if (textbox_password.Text != "" && textbox_id.Text != "") 
      { 
       //Check the cloud if the user is valid or not 
       if (Cloud_Form.Check_Cloud(textbox_id.Text, textbox_password.Text) == true) 
       { 

        user_id = textbox_id.Text; 
        user_pass = textbox_password.Text; 
        Network_Form network = new Network_Form(); 
        Network_Form.network.Show(); 
        Network_Form.network.Enabled = true; 
        this.Hide(); 
        this.Enabled = false; 
        Xml_Write_Login(); 
       } 
      } 

     } 
     catch(Exception ex) 
     { 
      this.Enabled = true; 
     } 
     label_response.Text = ""; 
     Button_status(true); 
    } 

public static bool Check_Cloud(string username, string password) 
    { 
     try { 
      string jsonstr2 = Call_Reseller_JsonStr(username, password); 
      JObject outp = JObject.Parse(jsonstr2); 
      string return_code = (string)outp["code"]; //check if it is successful or not 
      if (return_code.Equals("200") == true) 
      { 
       return true; 
      } 
      else { 
       Console.Write("false"); 
       return false; 
      } 
     } 
     catch(Exception ex) 
     { 
      return false; 
     } 
    } 

それはエラーcheck_cloud機能を提供します。エラーを表示せずにmyprogram.exeを実行するにはどうすればよいですか?前もって感謝します。

+1

私たちに見せてください! –

答えて

8

obj\Debugディレクトリから実行しないでください。objディレクトリは基本的に一時的なビルドアーチファクトです。代わりに、bin\Debugディレクトリから実行します。このディレクトリには、すべての依存関係(この場合はNewtonsoft.Json.dll)も存在しています。

ほとんどの場合、objディレクトリを無視することができます。関連性は非常に低いです。 binディレクトリは、有用な結果を含む実際の出力フォルダです。

+1

ありがとうございます。 – HelloWorld

関連する問題