访问应用程序设置时出错 [英] Error in accessing application settings

查看:70
本文介绍了访问应用程序设置时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个Windows应用程序正在启动它。



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");





已安装的程序正常运行..



在这方面可以有人帮助我...



在期待中感谢

问候

Sri



the installed program is running fine..

Can anybody help me in this regards...

Thanks in anticipation
Regards
Sri

推荐答案

那你可能没有钥匙( HK )。再看看它。



*注意:此方法已过时,已被System.Configuration!System.Configuration取代。 ConfigurationManager .AppSettings



祝你好运,

Edo
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


因为,app.config放在正确的位置,但没有重命名为应用程序名称..它仍然是app.config但它应该是applicationname.exe.config。
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".


这篇关于访问应用程序设置时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆