1
[RunInstaller(true)]
public partial class ProjectInstaller : Installer
{
private ServiceInstaller m_serviceInstaller;
private ServiceProcessInstaller m_processInstaller;
public ProjectInstaller()
{
string Names= ConfigurationManager.AppSettings["Names"].ToString();
System.Diagnostics.Debugger.Break();
m_serviceInstaller = new System.ServiceProcess.ServiceInstaller();
m_processInstaller = new System.ServiceProcess.ServiceProcessInstaller();
//
// serviceProcessInstaller1
//
m_processInstaller.Account = System.ServiceProcess.ServiceAccount.LocalSystem;
m_processInstaller.Password = null;
m_processInstaller.Username = null;
//
// serviceInstaller1
//
m_serviceInstaller.ServiceName = "Testing" + Names;
m_serviceInstaller.DisplayName = "Testing" + Names;
m_serviceInstaller.Description = "Testing" + Names;
//
// ProjectInstaller
//
this.Installers.AddRange(new System.Configuration.Install.Installer[] {
m_processInstaller,
m_serviceInstaller});
}
}
我的項目安裝程序代碼上面,它不會得到任何編譯錯誤,但是當我嘗試安裝它會回滾,因爲它會拋出異常System.Null referenceException。我也有雙確認,我的AppConfig沒有任何問題。ConfigurationManager.AppSettings得到錯誤的項目安裝
<appSettings>
<add key="Names" value="BOC" />
</appSettings>
我可以知道哪裏出了問題。
請檢查該配置文件發佈/在你的應用程序的運行路徑複製 – LittleSweetSeas
是的,它的存在 –