dll - 为什么 Visual Studio 2015 将 stdole.dll 和 Microsoft.AnalysisServices.AdomdClient.dll 添加到我的项目中?

标签 dll reference visual-studio-2015

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

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

我已经划掉了自定义引用。如果需要更多信息,请告诉我。这是我当前的引用资料:

enter image description here

enter image description here

最佳答案

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

在 Visual Studio 中,转到工具 > 选项 > 项目和解决方案 > 生成并运行。将“MSBuild 项目生成输出详细程度”设置更改为详细。现在清理并重建您的项目。

打开输出窗口并搜索 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 程序集。

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

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

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

关于dll - 为什么 Visual Studio 2015 将 stdole.dll 和 Microsoft.AnalysisServices.AdomdClient.dll 添加到我的项目中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31970967/

相关文章:

java - WeakReference 如何影响这个程序的工作

c++ - 构造函数中的引用初始化问题

c# - 如何在 Visual Studio 中调试 finally block ?

c++ - 视觉 C++ : memory debugger refresh while running

c++ - 在不编辑主 dll 的情况下覆盖另一个 dll 中的函数

python - 为 Python 或 SWIG 模块创建编译 C-dll,如何继续?

c++ - 如何延长表达式范围内临时变量的生命周期?

visual-studio - F# Visual Power Tools 不起作用

c - 如何在 MSVC 中访问 libsndfile-1.dll 中的函数?

visual-studio-2008 - 如何从崩溃的混合模式 exe/dll 中获取完整的堆栈跟踪?