【发布时间】:2020-07-24 05:04:42
【问题描述】:
我正在尝试将我的 C# 项目发布到可执行文件以便分发它。但是,我引用了“Interop.IWshRuntimeLibrary”,并且由于包含它,我的项目发布但随后在执行时崩溃:
An assembly specified in the application dependencies manifest was not found:
package: 'Interop.IWshRuntimeLibrary', version: '1.0.0.0'
path: 'Interop.IWshRuntimeLibrary.dll'
到目前为止我已经尝试过:
将 Interop.IWshRuntimeLibrary 的 Copy Local 和 Embed Interlop Types 属性设置为 true/false 的每种组合。
在 .csproj 文件中将以下标记设置为 true/false。
<PublishWithAspNetCoreTargetManifest>
- 安装 System.Runtime.InteropServices NuGet 包。
我的 .csproj 文件目前如下所示:
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>Project</RootNamespace>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
<ItemGroup>
<COMReference Include="IWshRuntimeLibrary.dll">
<Guid>f935dc20-1cf0-11d0-adb9-00c04fd58a0b</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>0</VersionMinor>
<WrapperTool>tlbimp</WrapperTool>
<Lcid>0</Lcid>
<Isolated>false</Isolated>
</COMReference>
</ItemGroup>
项目中的其他参考资料,例如 Newtonsoft 工作正常。我已经查阅了我可以在网络上找到的与此相关的每个线程。我最接近描述我的问题的另一个线程是Could not load file or assembly Interop.IWshRuntimeLibrary?,但我在那里也没有发现有用的信息。
理想情况下,我只想单击发布并发布到我桌面上的一个文件夹 - 最好是单个 .exe,但如果它可以工作,整个文件夹就可以了。我不知道我是否可能在某处遗漏了一步,因为我以前从未使用过发布功能。我不知道下一步该尝试什么。谢谢。
【问题讨论】:
标签: c# visual-studio com publish