我有一个 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>
我该如何解决这个问题?什么可能导致问题?