I am facing an issue when trying to call a function present in my web application from Console application.
My solution has two projects My solution - Web Project - Console Project
Code of my Console Application that calls web project function
namespace testConsoleApp
{
class mainClass
{
static void Main(string[] args)
{
Console.WriteLine("Hi");
try
{
outlookRoomBooking objOutlook = new outlookRoomBooking();
objOutlook.updateStatus();
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
Console.WriteLine("cron completed.");
Console.ReadKey();
}
}
}
Code of my Web Porject that i am using
namespace LVIS.includes
{
public class outlookRoomBooking
{
private string user = ConfigurationManager.AppSettings["user"].ToString();
private string passowrd = ConfigurationManager.AppSettings["passowrd"].ToString();
//Some more codes here //
}
}
When I run my console application, I get error "object reference not set to an instance of an object" when control enters the class in my web application i.e first line private string user = ConfigurationManager.AppSettings["user"].ToString();
I have added link reference of web.config of web project in my console project.
it seems class is not able to access ConfigurationManager.AppSettings when called from console application. class works fine when called from the same web project.
Aucun commentaire:
Enregistrer un commentaire