使用System.Deployment不存在吗?

发布于 2025-01-18 14:49:45 字数 549 浏览 1 评论 0原文

我尝试寻找system.deployment在我的Blazor Server应用程序中使用此代码:

但是System.Deployment不在我的项目系统中,也不在可用的项目参考中,我在Google上查找可下载的.dll链接,Microsoft似乎没有它。我想念什么?我尝试使用使用System.Deployment使用System.Deployment.Application,都不作用。

I've tried looking for System.Deployment to use this code in my Blazor Server application:
enter image description here

But System.Deployment is not in my project system, nor in the available Project References, I looked on Google to find a downloadable .dll link and Microsoft doesn't seem to have it. What am I missing? I've tried using System.Deployment and using System.Deployment.Application, neither works.

My project references, available libraries

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

淡淡離愁欲言轉身 2025-01-25 14:49:46

只需引用“ frameworkextract.system.system.system.deployment.deployment “ nuget” nuget。

祝你今天过得愉快,

Just reference the "FrameworkExtract.System.Deployment" nuget to your project.

Have a nice day,

南城旧梦 2025-01-25 14:49:46

如果您不想依靠外部软件包,则可以依靠注册表来跟踪其卸载中的应用程序版本。

基本上,当您去添加/删除并检查版本时。

RegistryKey? registryKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall\");

if (registryKey != null) return;

var programKeys = registryKey.GetSubKeyNames();

foreach (var keyName in programKeys)
{
    RegistryKey? programKey = registryKey.OpenSubKey(keyName);

    object? displayName = programKey?.GetValue("DisplayName");
    object? version = programKey?.GetValue("DisplayVersion");

    if (displayName != null && $"{displayName}" == <YourApplicationName>)
        VersionText.Text = $"Version: {version}";
        
    programKey?.Close();
}

registryKey.Close();

我将使用上面的答案,只需通过Nuget软件包安装缺失的功能,但是我想我会在这里留给任何想要更多地控制自己获取版本信息的人。

If you're not looking to rely on an external package, you can rely on the registry to keep track of your applications version in it's uninstall.

Basically when you go to Add/Remove and check a version.

RegistryKey? registryKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall\");

if (registryKey != null) return;

var programKeys = registryKey.GetSubKeyNames();

foreach (var keyName in programKeys)
{
    RegistryKey? programKey = registryKey.OpenSubKey(keyName);

    object? displayName = programKey?.GetValue("DisplayName");
    object? version = programKey?.GetValue("DisplayVersion");

    if (displayName != null && 
quot;{displayName}" == <YourApplicationName>)
        VersionText.Text = 
quot;Version: {version}";
        
    programKey?.Close();
}

registryKey.Close();

I'd use the above answer and just install the missing functionality through a nuget package but I thought I'd leave this solution here for anyone who wants a little more control over how they're getting the version info.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文