我有一个不同于程序集名称的 ClickOnce 发布名称。出于讨论目的,它是“App 6.0”。我在我的项目的属性中设置它。有没有办法从程序内部获取这个值?
最佳答案
添加对 Microsoft.Build.Tasks.v4.0.dll
的引用,然后运行:
if (null != AppDomain.CurrentDomain.ActivationContext)
{
DeployManifest manifest;
using (MemoryStream stream = new MemoryStream(AppDomain.CurrentDomain.ActivationContext.DeploymentManifestBytes))
{
manifest = (DeployManifest)ManifestReader.ReadManifest("Deployment", stream, true);
}
// manifest.Product has the name you want
}
else
{
// not deployed
}
DeployManifest 还可以提供 list 中的其他有用信息,例如 Publisher 或 SupportUrl。
关于c# - 我可以从应用程序内部获取 ClickOnce 发布的产品名称吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5918577/