在标准 .NET 应用程序中,
我可以添加 Office Core、Word、Excel 和 Powerpoint 的 COM 对象。一切正常。
某些命令需要 Office 核心程序集(例如,powerpoint 使用 Office.Core.MsoTriState.msoFalse/True 命令来执行某些操作,而 word 通过 Office.Core.MsoAutomationSecurity 使用 AutomationSecurity。
问题是当我构建一个 asp net core 应用程序时。 Nuget 具有 Excel、Word 和 Powerpoint 的包,如果我不引用任何 Office.Core 项目,这些包将正常工作,但每当我引用一个项目时,我都会收到此错误:
The type 'MsoTriState' is defined in an assembly that is not referenced. You must add a reference to assembly 'office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.
我尝试手动将 MSO.DLL 添加到项目中,但仍然出现相同的错误。
我还尝试添加所有 COM 对象而不是 nuget 包,但在对象创建时出现如下错误:
Could not load file or assembly 'Interop.Microsoft.Office.Interop.Excel, Version=1.8.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.'
如何将 Microsoft.Office.Core 包添加到我的 asp net core 2.0 应用程序中?