c# - C# 类型在命名空间中不存在/名称在当前上下文中不存在
问题描述
using System.Deployment.Application;
我的代码开头有一行。下面有一条红色的波浪线Application
,将鼠标悬停在它上面会给我以下信息:
The type or namespace name 'Application' does not exist in the namespace 'System.Deployment' (are you missing an assembly reference?) (CS0234)
当我使用它时,这当然会给我带来问题ApplicationDeployment
,它说The name 'ApplicationDeployment' does not exist in the current context (CS0103)
为什么 Visual Studio 告诉我这Application
不是 的一部分System.Deployment
?
解决方案
在 Visual Studio Code 中,打开 your.csproj 文件。在此文件中,您可以添加对 System.Deployment 的程序集引用,它应该可以解决您的问题。
参考:
<Reference Include="System.Deployment"/>
这将添加到 .csproj 文件的 ItemGroup 部分
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="System.Deployment"/>
</ItemGroup>
推荐阅读
- sql - Redshift 创建列表并用它搜索不同的表
- python - 如何在 if 语句中使用随机选择的函数作为条件?
- python - 尝试从 Python 中的 pandas 数据框列获取唯一值时,如何克服不可散列的类型:“列表”错误
- android - 如何在笔记本电脑中使用第二个 GPU 来启动模拟器 Android Studio
- java - 如何将地址字段信息传递给 google 地方服务
- swift - 查找包含具有特定值的对象的对象的索引
- rest - 如何在 @MultipartForm Pojo 中使用 UUID?
- jquery - 限制 Jquery Datables Editor Modal Popup 输入字段上的空白
- django - websocket接收不完整的数据
- angular - 使用 Angular 元素封装 Angular 服务