【发布时间】:2013-07-03 08:23:01
【问题描述】:
我有一个 Windows 桌面应用程序,从中启动一个 Web 应用程序。
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();
}
它在我的机器上运行良好。然后我创建了一个安装程序来安装它,但是当我在生产机器上运行我新安装的程序时,我得到了以下异常:
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)
如果我换行
Process.Start("IExplore.exe", url);
到
Process.Start("IExplore.exe","http://localhost:49916/Express/Login.aspx?yek@soh=6775228");
然后程序运行。
我的app.config如下:
<configuration>
<appSettings>
<add key="HK" value="PRO2"/>
<add key="ClientSettingsProvider.ServiceUri" value=""/>
</appSettings>
<startup>
<supportedRuntime version="v2.0.50727"/>
</startup>
</configuration>
我该如何解决这个问题?什么可能导致问题?
【问题讨论】:
-
您的 app.config 的 appSettings 部分是什么样的?
-
这是我的 app.config 文件 -
感谢您编辑我的问题。如果您能帮助我,那就太好了。
标签: c# .net web-config desktop-application windows-applications