c# - 在 Visual Studio 2015 中构建 VSIX 项目时出现错误 CS1759

标签 c# .net visual-studio visual-studio-2015

我创建了一个新的 VSIX 项目,添加了一个新的自定义命令项,尝试构建,但我遇到了这 2 个错误:

error CS1759: Cannot embed interop types from assembly 'Microsoft.VisualStudio.OLE.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' because it is missing either the 'System.Runtime.InteropServices.ImportedFromTypeLibAttribute' attribute or the 'System.Runtime.InteropServices.PrimaryInteropAssemblyAttribute' attribute.

error CS1759: Cannot embed interop types from assembly 'Microsoft.VisualStudio.Shell.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' because it is missing either the 'System.Runtime.InteropServices.ImportedFromTypeLibAttribute' attribute or the 'System.Runtime.InteropServices.PrimaryInteropAssemblyAttribute' attribute.

可能是什么问题?

如果有帮助,我遵循了这个 Microsoft 指南: https://msdn.microsoft.com/en-us/library/cc138589.aspx

谢谢!

  • 编辑: 我将引用“...shell.interop”和“...OLE.interop”的属性中的“嵌入互操作类型”字段从 True 更改为 False,并且它有效。有人知道为什么吗? 谢谢。

最佳答案

正如作者提到的,将这两个程序集的 Embed Interop Types 属性更改为 false。

关于c# - 在 Visual Studio 2015 中构建 VSIX 项目时出现错误 CS1759,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32166491/

相关文章:

c# - MSBuild 项可以使用目标设置的属性吗?

c# - 使用 linq 和 lambda 表达式简化传统的 foreach 嵌套循环

-1 的 C# 7 二进制文字

c# - 如何从 XmlDocument 中选择具有 XML 命名空间的 XML 节点?

c# - Asp .Net Core 中的自定义模型绑定(bind)

c# - 声明属性时 "=>"在 .Net C# 中做什么?

c# - c#中如何将DataTable中的值转换为字符串数组

c# - 将泛型类型参数转换为 C# 中的特定类型

c++ - 在 Visual Studio 中创建 hpp 文件

python - 将 CNTK virtualenv 添加到 Visual Studio Python 项目