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
是的,它的存在 –