[英]Installing Windows service C# inno self using managedinstaller class
使用類似於此Inno Setup for Windows服務的代碼?
在Windows 7盒(VS 2010)上,當我嘗試運行Inno安裝程序時,得到以下結果
找不到帶有RunInstallerAttribute.Yes屬性的公共安裝程序
如果與標准Windows安裝程序一起運行,則該服務有效; 這是代碼:
[RunInstaller(true)]
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
public static void Main(string[] args)
{
if (args.Count()==1)
{
string parameter = string.Concat(args);
switch (parameter)
{
case "--install":
ManagedInstallerClass.InstallHelper(new string[] {Assembly.GetExecutingAssembly().Location});
break;
case "--uninstall":
ManagedInstallerClass.InstallHelper(new string[]
{"/u", Assembly.GetExecutingAssembly().Location});
break;
}
}
else
{
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new SkyLibrarian()
};
ServiceBase.Run(ServicesToRun);
}
}
}
有沒有人對此問題有經驗? 我以右鍵單擊以管理員身份運行安裝程序。 謝謝
西蒙·諾本
在錯誤消息和粘貼的代碼中明確指出了該問題。 該錯誤指出“沒有找到具有RunInstallerAttribute.Yes屬性的公共安裝程序”。 在代碼段中,將Program類(將RunInstaller屬性設置為true)聲明為internal 。
將您的類聲明更改為public,它應該可以正常工作。
[RunInstaller(true)]
public static class Program
這是一個簡單的錯誤。 ProjectInstaller文件已損壞,並已從解決方案中刪除。 原本打算取代它,但有人“忘了”。 一旦找到問題,問題就會自行解決。 該錯誤消息不是描述性的,也沒有幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.