找不到类型或命名空间 'DocumentFormat' - 仅在构建时 - 但智能感知显示类型可用

Type or namespace 'DocumentFormat' could not be found - only on build - but intellisense shows the type as available

我已经从以下网站下载了 Power Tools for Open XML:-

https://powertools.codeplex.com/

我在 VS2012 中打开解决方案,然后更新引用 - DocumentFormat.OpenXmlWindowsBase

问题是:-

当我在 class 的顶部开始键入名称空间时,Visual Studio 智能感知显示名称空间,但是当我构建解决方案时,我从所有 class es 使用这个命名空间的地方-

The type or namespace 'DocumentFormat' could not be found.

根据您的要求和环境,您需要匹配 PowerToolsOpenXML SDK 个版本。

PowerTools 2.2(现在是 codeplex 上的默认下载)使用 DocumentFormat.OpenXml 版本 2.0.5022.0 附带 OpenXml SDK 2.0.
该项目基于 .NET Framework 3.5.

PowerTools for OpenXML 3.0 版本 3.*(也可在 https://powertools.codeplex.com/releases/view/74771 下载)使用 DocumentFormat.OpenXml 版本 2.5.5631.0 附带 OpenXml SDK 2.5.
本项目基于 .NET Framework 4.0+.

也许其他人仍然面临问题,我也是。

转到 nuget 包管理器并搜索 openxml 并从那里安装。