I have .NET console application and there is a problem with newtonsoft library. When I start console application with Visual studio by clicking start button, there is no problem. Everything is good. However, If i try to run myprogram.exe under the obj/debug folder, it gives following error:
"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;
}
}
it gives error check_cloud function. How can i run myprogram.exe without getting error? Thanks in advance.
Don't run it from the obj\Debug
directory - the obj
directory is basically temporary build artefacts. Instead, run it from the bin\Debug
directory, where you'll find all the dependencies (in this case Newtonsoft.Json.dll
) are present as well.
Basically, you can ignore the obj
directory in almost all cases - it's extremely rare for it to be relevant. The bin
directory is the real output folder containing useful results.
See more on this question at Stackoverflow