我从事的 C# 项目有一个程序集,stdole.dll
其中包含我的开发 PC 上位于C:\WINDOWS\assembly\GAC\stdole\7.0.3300.0__b03f5f7f11d50a3a\stdole.dll
.
我不确定这个程序集最初是从哪里来的。我注意到有一个提供它的 Nuget 包:https ://www.nuget.org/packages/stdole/17.0.0-previews-1-31314-256虽然我们没有使用它。
我的程序集一直在使用预先存在的 GAC 文件;当我从 GAC stdole 引用切换到 Nuget 版本时,从我的 CSPROJ 中删除了以下内容:
<COMReference Include="stdole">
<Guid>{00020430-0000-0000-C000-000000000046}</Guid>
<VersionMajor>2</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>primary</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
而这增加了:
<Reference Include="Microsoft.VisualStudio.Interop, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\hap\Build\packages\Microsoft.VisualStudio.Interop.17.0.0-previews-1-31314-256\lib\net472\Microsoft.VisualStudio.Interop.dll</HintPath>
</Reference>
<Reference Include="netstandard" />
<Reference Include="stdole, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\hap\Build\packages\stdole.17.0.0-previews-1-31314-256\lib\net472\stdole.dll</HintPath>
</Reference>
GAC 文件有版本7.0.9466.1
,Nuget 包有17.0.31314.256
.
我认为最好使用 Nuget 源并确保我们分发它的依赖项,而不是仅仅引用一些恰好在我的系统上的 DLL。但我真的不明白它们之间有什么区别(如果有的话)。
stdole 包提供的链接都没有用。他们是:
从 VS 中的 Nuget:https ://aka.ms/vsextensibility (它重定向到一个明显不相关的“Visual Studio SDK”页面,似乎没有提到 stdole)
从 Nuget网站发布说明链接转到“Visual Studio 2015 Update 2 Release Notes”,也似乎无关紧要
所以这些似乎是死胡同。
杂项/背景信息
该应用程序确实需要stdole
,因为它与一些旧版 VB6 代码交互,并且StdPicture
必须交换对象。
出现这个问题是因为我的应用程序在一台 PC 上特别出现以下错误:
Could not load file or assembly 'stdole, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
此错误未在其他任何地方发生。正因为如此,我担心我们遗漏了应该安装的依赖项,也许幸运的是大多数 PC 上都存在一些依赖项,但不是全部。