NetOfficeFw / NetOffice

🌌 Create add-ins and automation code for Microsoft Office applications.
MIT License
700 stars 145 forks source link

Upgrade from NetOffice to NetOfficeFw #404

Closed mc0re closed 9 months ago

mc0re commented 9 months ago

When upgrading, I faced the following issue:

PowerPointReference.vb(424,20): error BC30652: Reference required to assembly 'OfficeApi, Version=1.9.4.0, Culture=neutral, PublicKeyToken=297f57b43ae7c1de' containing the type 'MsoTriState'. Add one to your project.
PowerPointReference.vb(424,34): error BC30451: 'MsoTriState' is not declared. It may be inaccessible due to its protection level.

It's an old .NET Framework project. All references to NetOffice were replaced with NetOfficeFw, so now the project includes the following:

    <Reference Include="NetOffice, Version=1.9.4.0, Culture=neutral, PublicKeyToken=297f57b43ae7c1de, processorArchitecture=MSIL">
      <HintPath>..\packages\NetOfficeFw.Core.1.9.4\lib\net462\NetOffice.dll</HintPath>
      <EmbedInteropTypes>False</EmbedInteropTypes>
    </Reference>
    <Reference Include="PowerPointApi, Version=1.9.4.0, Culture=neutral, PublicKeyToken=297f57b43ae7c1de, processorArchitecture=MSIL">
      <HintPath>..\packages\NetOfficeFw.PowerPoint.1.9.4\lib\net462\PowerPointApi.dll</HintPath>
      <EmbedInteropTypes>False</EmbedInteropTypes>
    </Reference>

There is no package named OfficeApi. What am I missing?

jozefizso commented 9 months ago

Please post your whole project to troubleshoot the issue.

mc0re commented 9 months ago

This one: https://github.com/mc0re/next-player (not yet upgraded on GitHub). The project in question is PlayerActions.

jozefizso commented 9 months ago

Thanks @mc0re, this was very helpful.

I see the project is using two nuget packages from the old NetOffice which actually bundle four different libraries.

The NetOfficeFw has a different structure of nuget packages.

I would suggest to use NuGet to first remove the NetOffice.PowerPoint and the NetOffice.Core packages. After that add the newest NetOfficeFw.PowerPoint using NuGet to correctly setup the project.

jozefizso commented 9 months ago

Here is a guide: https://netoffice.io/migrate-notice/

mc0re commented 9 months ago

I did, and the result is posted as OP.

mc0re commented 9 months ago

Okay, I did it again, and this time it worked. Probably, some caching issue in VS. Sorry for bothering.

jozefizso commented 9 months ago

You are welcome @mc0re. Happy coding.