Click here to Skip to main content
15,891,938 members
Please Sign up or sign in to vote.
4.33/5 (2 votes)
Hi
I have a windows application from which an web application is starting.

C#
private void Home_Load(object sender, EventArgs e)
       {
           string url = string.Format("http://localhost:49916/Express/Login.aspx?yek@soh={0}", System.Configuration.ConfigurationSettings.AppSettings["HK"].ToString());

           Process.Start("IExplore.exe", url);
           this.Close();
       }


It is working fine in my source code.

I created a setup for this application.
And installed.. successful.. but when I tried to run the installed application.. it is throwing error like below.

System.NullReferenceException: Object reference not set to an instance of an object.
   at HospitalClient_App.Home.Home_Load(Object sender, EventArgs e)
   at System.Windows.Forms.Form.OnLoad(EventArgs e)
   at System.Windows.Forms.Form.OnCreateControl()
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ContainerControl.WndProc(Message& m)
   at System.Windows.Forms.Form.WmShowWindow(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)



If I change the line
C#
Process.Start("IExplore.exe", url);

to
C#
Process.Start("IExplore.exe","http://localhost:49916/Express/Login.aspx?yek@soh=6775228");


the installed program is running fine..

Can anybody help me in this regards...

Thanks in anticipation
Regards
Sri
Posted

Then you probably don't have the key ("HK") in the AppSettings. Have another look at it.

* NOTE: This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings

Good luck,
Edo
 
Share this answer
 
v2
Because, the app.config is placed in the right location but not renamed to the application name.. it was still "app.config" but it supposed to be "applicationname.exe.config".
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900