【问题标题】:Why is Visual Studio 2015 adding stdole.dll and Microsoft.AnalysisServices.AdomdClient.dll to my project?为什么 Visual Studio 2015 将 stdole.dll 和 Microsoft.AnalysisServices.AdomdClient.dll 添加到我的项目中?
【发布时间】:2018-11-27 00:01:51
【问题描述】:

在以前版本的 Visual Studio 中,这些 DLL 不会添加到我的项目中。我的猜测是我的其中一个引用依赖于这些 DLL。根据我的阅读,突出显示的Microsoft.Office.Interop.Excel 可能就是那个。谁能证实这一点?我还应该注意,即使我将它们从项目中排除,VS 2015 也会始终发布这些 DLL。如果我删除它们,VS 2015 将重新制作它们。

编辑:我已确认 Excel 和 Office 引用是导致包含 stdole.dll 的原因。请参阅下面的选定答案以删除 stdole.dll。

我已经删除了自定义引用。如果需要更多信息,请告诉我。这是我目前的参考资料:

【问题讨论】:

  • 怎么样?我的第一个反对票。没有反馈的否决票是非常低效的。
  • 我对这个问题很感兴趣,因为我所做的所有应用程序都会弹出 stdole.dll。我点击一次发布,它导致 Visual Studio 2015 失败。它可能与这个问题无关,但其他人可能会发现这个问题正在搜索那个 dll。他用他的签名副本替换了另一个人:iznum.wordpress.com/2013/04/22/…
  • 另一个人发布了一个关于此的错误:connect.microsoft.com/VisualStudio/feedback/details/1658072/…
  • @249076 我猜您的应用程序有“嵌入互操作类型”=false 的引用,并且可能在升级到 VS2015 后现在出现。我在下面更新了我的答案,这可能会对您有所帮助。

标签: dll reference visual-studio-2015


【解决方案1】:

正如其他人所指出的,stdole.dll 是一组 Office COM 互操作组件的主互操作程序集。您可以通过执行以下操作来确定它为何被包含在您的项目中。

在 Visual Studio 中,转到 Tools > Options > Projects and Solutions > Build and Run。将“MSBuild 项目构建输出详细程度”设置更改为Detailed。现在清理并重建您的项目。

打开输出窗口并搜索stdole。你应该找到这样的部分:

25>  Dependency "stdole, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
25>      Resolved file path is "D:\Program Files (x86)\Microsoft Visual Studio 12.0\Visual Studio Tools for Office\PIA\Common\stdole.dll".
25>      Reference found at search path location "{Registry:Software\Microsoft\.NETFramework,v4.0,AssemblyFoldersEx}".
25>          For SearchPath "D:\Git\FoobarServices\Dependencies\Dependencies".
25>          Considered "D:\Git\FoobarServices\Dependencies\stdole.winmd", but it didn't exist.
25>          Considered "D:\Git\FoobarServices\Dependencies\stdole.dll", but it didn't exist.
25>          Considered "D:\Git\FoobarServices\Dependencies\stdole.exe", but it didn't exist.
25>          For SearchPath "{CandidateAssemblyFiles}".
25>          Considered "Dependencies\CrystalDecisions.CrystalReports.Engine.dll", but its name "CrystalDecisions.CrystalReports.Engine" didn't match.
25>          Considered "Dependencies\CrystalDecisions.Enterprise.Framework.dll", but its name "CrystalDecisions.Enterprise.Framework" didn't match.
25>          Considered "Dependencies\CrystalDecisions.Enterprise.InfoStore.dll", but its name "CrystalDecisions.Enterprise.InfoStore" didn't match.
25>          Considered "Dependencies\CrystalDecisions.ReportSource.dll", but its name "CrystalDecisions.ReportSource" didn't match.
25>          Considered "Dependencies\CrystalDecisions.Shared.dll", but its name "CrystalDecisions.Shared" didn't match.
25>          Considered "Dependencies\CrystalDecisions.Web.dll", but its name "CrystalDecisions.Web" didn't match.
25>          For SearchPath "{TargetFrameworkDirectory}".
25>          Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\stdole.winmd", but it didn't exist.
25>          Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\stdole.dll", but it didn't exist.
25>          Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\stdole.exe", but it didn't exist.
25>          For SearchPath "{Registry:Software\Microsoft\.NETFramework,v4.0,AssemblyFoldersEx}".
25>          Considered AssemblyFoldersEx locations.
25>      Required by "CrystalDecisions.Web, Version=11.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304, processorArchitecture=MSIL".
25>      Required by "CrystalDecisions.ReportSource, Version=11.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304, processorArchitecture=MSIL".
25>      Required by "CrystalDecisions.CrystalReports.Engine, Version=11.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304, processorArchitecture=MSIL".
25>      Required by "CrystalDecisions.Enterprise.InfoStore, Version=11.5.3300.0, Culture=neutral, PublicKeyToken=692fbea5521e1304".
25>      The ImageRuntimeVersion for this reference is "v1.0.3705".

您可以在底部看到 Visual Studio 搜索程序集的位置以及需要它的位置。在我的例子中,它是一堆旧的 Crystal Reports 程序集。

有时您可以按照 Tony 的建议通过依赖项嵌入互操作类型,但并非总是如此。对我来说,Crystal Reports 程序集不支持这一点。

我通过将stdole.dll(32KB,数字签名)从C:\Program Files (x86)\Microsoft.NET\Primary Interop Assemblies\ 复制到我项目内的“依赖项”文件夹中来解决了这个问题(以及scottsanpedro 提到的阴险问题)。我将文件添加到我的项目中,并添加了对其的显式引用(添加引用 > 浏览)。最后我打开了新引用的属性并将Embed Interop Types 设置为True

这似乎是一个更好的情况。我不必担心获得未签名版本的程序集。

【讨论】:

  • 好消息,尼克。我将在关于查找哪些类引用 dll 的答案中参考您的答案。
  • 如果将Embed Interop Types设置为True,是否还需要stdole.dll?我的应用不再需要它。
【解决方案2】:

如果您有选择,请使用嵌入互操作类型并将 stdole.dll 全部排除在外,否则每次移动没有 stdole.dll 的应用程序(新服务器或开发机器)时都会遇到问题签名。

问题:有一个引用需要 stdole.dll 并且 stdole.dll 现在被自动推送到 bin 文件夹。

解决方案:

  • 找到需要 stdole.dll 的参考(更多关于如何在下面执行此操作)
  • 转到它的属性(右键单击->属性)
  • 将“嵌入互操作类型”从 false 更改为 true。

如何找到引用:当您单击引用的属性时,检查“嵌入互操作类型”是否设置为 false。为了进一步挖掘,Nick's answer 提供了一些很棒的信息。

到目前为止我已经确认使用 stdole.dll 的参考文献(可能还有更多的办公程序)

  • 办公室

  • Excel

  • 核心

  • Crystal Reports(感谢 Lithium。正如 Nick 指出的那样,您可能没有设置 Embed Interop Types=true 的优势)

  • NetOffice OfficeApi

如果您发现更多,请将它们添加到此列表中或在 cmets 中记录它们,我会这样做。

Hans Passant 强烈反对在此处设置Embed Interop Types=falseWhat's the difference setting Embed Interop Types true and false in Visual Studio?

Scott Hanselman 还谈到了“嵌入互操作类型”在这里的作用:http://www.hanselman.com/blog/CLRAndDLRAndBCLOhMyWhirlwindTourAroundNET4AndVisualStudio2010Beta1.aspx

【讨论】:

  • 您好,感谢您的回答。您可以将 Crystal Reports dll 添加到使用 stdole.dll 的引用列表中
  • 我还发现 NetOffice OfficeApi 库需要 stdole.dll - 这很可能是因为它在后台利用了 Microsoft.Office.Interop.Word 库:)
【解决方案3】:

我多年来一直在处理这个问题。

每当我从网络平台安装任何东西或任何更新时,stdole.dll 都会被替换为未签名的版本。不久前我向 Microsoft 报告了该错误,但被置若罔闻。

我去 C:\Program Files (x86)\Microsoft.NET\Primary Interop Assemblies 并从这里复制签名版本 (22kb) 并替换 C:\Program Files (x86)\Microsoft Visual Studio 14.0 中的版本\Visual Studio Tools for Office\PIA\Common (16kb) 即可解决问题。

斯科特

【讨论】:

  • Scott,我找到了一种方法来做到这一点,而无需再弄乱 stdole.dll。刚刚更新了我的答案。仍然投票给你,因为你给了我另一个解决方法。
【解决方案4】:

在我的情况下,我发现切换依赖于 stdole.dll 的程序集的 Copy Local 属性,保存项目,然后将属性切换回其原始值,最后再次保存项目解决了问题。此属性也可能与其他遇到此问题的人的 Embed Interop Types 属性有关。

这样做是将 Copy Local 属性显式保存到 .xxproj 文件中。否则,此属性的状态不在项目文件中,并假定为默认值。我无法解释为什么这会起作用,因为项目文件中存在的属性不会更改 Visual Studio 中显示的值,也不会导致实际发布的程序集发生更改。在来回切换它们之后,我也没有导致这些属性从它们最初显示的值发生变化。

我确实注意到,甚至在我找到解决方法之前,我就看到清理项目并重建它不会导致 stdole.dll 被复制到 bin。 stdole.dll 是在发布之后才出现的。

【讨论】:

  • 好消息。现在你让我想知道我是否删除了设置为 Copy Local 的引用,而我重新添加的引用没有。
  • 您对“嵌入互操作类型”的直觉是正确的。我找到了问题并更新了我的答案。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-08-15
  • 2020-02-19
  • 2017-04-18
  • 1970-01-01
  • 2016-06-21
相关资源
最近更新 更多