在curent上下文中不存在名称'applicationdeployment'。 [英] The name 'applicationdeployment' does not exists in the curent context.

查看:229
本文介绍了在curent上下文中不存在名称'applicationdeployment'。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有使用Visual Studio 2017(社区版)开发的#WPF应用程序。



我试图引用ApplicationDeployment.CurrentVersion 。 VS说它无法解决'ApplicationDeployment',即使我已经包含了使用System.Deployment;声明。



以下无用的代码说明了这个问题。



如果有人愿意,我将永远感激不尽将此代码粘贴到VS中,帮助我解决此问题。



谢谢!



I have a c# WPF app I am developing using Visual Studio 2017 (Community version).

I am trying to reference ApplicationDeployment.CurrentVersion. VS is saying it cant resolve 'ApplicationDeployment', even though I have included a "using System.Deployment;" statement.

The following useless code illustrates the problem.

I would be eternally grateful if someone would paste this code into VS and help me resolve this issue.

Thanks!

using System;
using System.Deployment;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;


namespace WpfApp2
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            //
            // ERROR IS BELOW
            //

            var x = ApplicationDeployment.CurrentDeployment.CurrentVersion;

        }
    }
}





我尝试过:



我已经尝试了各种方法来获得引用来解决,没有运气



What I have tried:

I have tried all sorts of ways to get the reference to resolve, with no luck

推荐答案

使用System.Deployment.Application;
Try

代替

 instead of 
using System.Deployment;


这不起作用。



当我输入System.Deployment。时,IntelliSense只提供{} internal。



如果我继续输入System.Deployment.Application,它表示应用程序在命名空间System.Deployment中不存在
That doesn't work.

When I am typing "System.Deployment.", IntelliSense only offers up "{} internal".

If I go ahead and type "System.Deployment.Application", it says that Application doesn't exist in namespace System.Deployment"

问题已经解决。



我需要将System.Deployment程序集添加到References。
The issue has been resolved.

I needed to add the "System.Deployment" assembly to the References.


这篇关于在curent上下文中不存在名称'applicationdeployment'。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆