2012-03-09 18 views
1

我正在使用ClickOnce功能部署的在线唯一winform应用程序,它通过FTP上传到服务器,用户通过http在线执行它。在线ClickOnce部署应用程序并在桌面/开始菜单上放置一个图标

正如您可能已经知道的,Online only功能不会在桌面上放置任何图标,因此每次运行时用户都需要运行setup.exe文件来执行此操作。

我的问题是,如果有反正我实际上可以创建一个图标,可能指向安装文件或任何解决方法,以确保用户有一个简单易用的方法来运行应用程序,而无需查找设置文件每次?

用户对计算机的了解可能并不多,因此每次浏览下载的文件都很困难,而且我想让他们更容易。

我知道,如果我执行离线/在线应用程序,它将解决问题,但我希望它只能在线。

任何想法?

回答

1

您可以在第一次应用程序运行时手动创建桌面快捷方式,并将其指向您的应用程序的url或下载文件的路径(我猜如果用户删除文件,url会更安全)。代码可以是这个样子(需要调整您的网址):

void CheckForShortcut() 
{ 
    ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment; 

    if (ad.IsFirstRun) 
    { 
     Assembly code = Assembly.GetExecutingAssembly(); 

     string company = string.Empty; 
     string description = string.Empty; 

     if (Attribute.IsDefined(code, typeof(AssemblyCompanyAttribute))) 
     { 
      AssemblyCompanyAttribute ascompany = (AssemblyCompanyAttribute)Attribute.GetCustomAttribute(code, 
       typeof(AssemblyCompanyAttribute)); 
      company = ascompany.Company; 
     } 

     if (Attribute.IsDefined(code, typeof(AssemblyDescriptionAttribute))) 
     { 
      AssemblyDescriptionAttribute asdescription = (AssemblyDescriptionAttribute)Attribute.GetCustomAttribute(code, 
       typeof(AssemblyDescriptionAttribute)); 
      description = asdescription.Description; 
     } 

     if (company != string.Empty && description != string.Empty) 
     { 
      string desktopPath = string.Empty; 
      desktopPath = string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), 
       "\\", description, ".appref-ms"); 

      string shortcutName = string.Empty; 
      shortcutName = string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.Programs), 
       "\\", company, "\\", description, ".appref-ms"); 

      System.IO.File.Copy(shortcutName, desktopPath, true); 
     } 

    } 
} 

学分http://geekswithblogs.net/murraybgordon/archive/2006/10/04/93203.aspx

2

你有什么理由为希望在线的ClickOnce只应用?我总是建议离线,除非你的应用程序真的是一个边缘案例。

在线和离线之间没有什么区别。所有相同的文件都下载到客户端上的相同位置。离线应用向“添加/删除程序”,开始菜单快捷方式和可选桌面快捷方式(如果您的目标是.NET 3.5+)添加条目。通过添加/删除程序卸载的能力是关键。当用户安装问题时,它使支持您的应用程序更容易

此外,您提到每次运行setup.exe的用户。这是不必要的。 setup.exe将包含引导的先决条件,然后在完成时启动应用程序。如果用户运行一次setup.exe,他们只需要点击链接到.application文件。这肯定会加快应用程序的启动时间。而且,在很多情况下,用户必须拥有管理员权限才能运行setup.exe;点击.application不会(假设有管理员权限的人已经运行setup.exe)。

总之,这里真的没有答案:)。但是...

  1. 确保您的推理理解为不进行脱机安装。
  2. 运行setup.exe一次后,指示用户单击.application url(或桌面快捷方式,如果切换到脱机状态)而不是setup.exe。
0

据我所知,没有可靠的方法来运行在线只ClickOnce应用程序比创建该setup.exe的快捷方式。

相关问题