核心2.0和Office互操作-microsoft.office.core软件包在哪里? [英] core 2.0 and office interop - where is the microsoft.office.core package?
问题描述
在标准.NET应用中, 我可以为Office Core,Word,Excel和Powerpoint添加COM对象.一切正常.
In a standard .NET app, I can add the COM objects for Office Core, Word, Excel, and Powerpoint. Everything works fine.
某些命令需要Office核心程序集(例如,powerpoint将Office.Core.MsoTriState.msoFalse/True命令用于某些操作,而单词则通过Office.Core.MsoAutomationSecurity使用AutomationSecurity.
The Office core assembly is needed for some commands (for example, powerpoint uses Office.Core.MsoTriState.msoFalse/True commands for some actions, and word uses AutomationSecurity via Office.Core.MsoAutomationSecurity.
问题是当我构建一个ASP Net Core应用程序时. Nuget具有Excel,Word和Powerpoint的软件包,如果我未引用任何Office.Core项,它们将正常运行,但是任何时候我引用一个项目,我都会收到此错误:
The problem is when I am building an asp net core app. Nuget has the packages for Excel, Word, and Powerpoint, which will work properly if I don't reference any Office.Core items, but anytime I reference one I get this error:
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手动添加到项目中,但仍然遇到相同的错误.
I've tried manually adding the MSO.DLL to the project, but still get the same error.
我也尝试添加所有COM对象而不是nuget包,但是在创建对象时出现了这样的错误:
I've also tried adding all the COM objects instead of the nuget packages, but I get an error like this on object creation:
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应用程序中?
How do I add the Microsoft.Office.Core package to my asp net core 2.0 application?
推荐答案
作为替代方案(直到有人能够提供真实答案),我一直在使用NetOffice nuget程序包,因为它们提供了核心程序包.似乎从官方的Microsoft Office nuget包中丢失了.
As an alternative (until someone is able to provide a real answer), I have been playing with the NetOffice nuget packages instead, as they provide the core package that seems to be missing from the official Microsoft Office nuget packages.
这篇关于核心2.0和Office互操作-microsoft.office.core软件包在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!