繁体   English   中英

System.IO.FileNotFoundException,Newtonsoft.Json .Net

[英]System.IO.FileNotFoundException, Newtonsoft.Json .Net

我有.NET控制台应用程序,并且newtonsoft库有问题。 当我通过单击开始按钮使用Visual Studio启动控制台应用程序时,没有问题。 万事皆安。 但是,如果我尝试在obj / debug文件夹下运行myprogram.exe,则会出现以下错误:

“ System.IO.FileNotFoundException:'Newtonsoft.Json,版本= 9.0.0.0,区域性=中性,PublicKeyToken = 30ad4fe6b2a6aeed'文件或编译,或其依赖项之一。系统找不到指定的文件。文件名:'Newtonsoft .Json,版本= 9.0.0.0,文化=中性,PublicKeyToken = 30ad4fe6b2a6aeed'位置:Barcode_Form.Cloud_Form.Check_Cloud(字符串用户名,字符串密码)“

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而不会出现错误? 提前致谢。

不要从obj\\Debug目录运行它obj目录基本上是临时构建工件。 而是从bin\\Debug目录运行它,在这里您还将找到所有依赖项(在本例中为Newtonsoft.Json.dll )。

基本上,您几乎可以在所有情况下都忽略obj目录-很少具有相关性。 bin目录是包含有用结果的实际输出文件夹。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM