core 2.0 and office interop - where is the microsoft.office.core package?

自闭症网瘾萝莉.ら 提交于 2019-12-12 14:05:13

问题


In a standard .NET app, I can add the COM objects for Office Core, Word, Excel, and Powerpoint. Everything works fine.

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.

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'.

I've tried manually adding the MSO.DLL to the project, but still get the same error.

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.'

How do I add the Microsoft.Office.Core package to my asp net core 2.0 application?


回答1:


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.



来源:https://stackoverflow.com/questions/49458018/core-2-0-and-office-interop-where-is-the-microsoft-office-core-package

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!