[英]System.IO.FileNotFoundException: 'Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0,
[英]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.