Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NET Forms web.Config
Hi
I have a windows application from which an web application is starting.
 
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
 Process.Start("IExplore.exe", url); 
to
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 2-Jul-13 22:43pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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".
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 6,569
1 Sergey Alexandrovich Kryukov 6,168
2 DamithSL 5,228
3 Manas Bhardwaj 4,717
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web02 | 2.8.1411022.1 | Last Updated 18 Jul 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100