How to setup Excel Interop for Exccel 365

Zach Sim 26 Reputation points
2022-07-24T23:40:22.707+00:00

I've been attempting to setup a project that allows me to use Excel Interop in C# on the Office 365 version (I need to create and edit some sheets to automate some tasks from work involving CSV files). However almost every attempt has resulted in the following error...

Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'. The system cannot find the file specified.
File name: 'office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'
at Program.<Main>$(String[] args)

I get that I'm missing an assembly or dll however I have no idea how I could fix it. I've attempted multiple solutions, adding various references and packages however I've had almost no success.
I only have 365 installed on this machine and what confuses me more is that by reverting to version 12.0.4518.1014 and installing a third party package simply called "Office" from NuGet, the project mostly works, aside from it telling me to use .Net Framework 4.8 instead of .Net Core 6.0
I've also had some others report that for some reason they can't get the version of interop to function with Office 365. Is there some step or package that we're missing?

I'm currently using Visual Studio 2022 with the Microsoft.Office.Interop.Excel package in C#, It's a simple console app. if any other information is needed feel free to ask.

Microsoft 365 and Office | Development | Other
Developer technologies | C#
{count} votes

3 answers

Sort by: Most helpful
  1. ShuaiHua Du 636 Reputation points
    2022-07-25T05:53:26.283+00:00

    Could find "Microsoft.Office.Interop.Excel" in your GAC path?

    Reference below path:

    224213-image.png


  2. peiye zhu 165 Reputation points
    2023-09-03T03:03:32.5066667+00:00

    as to .Net Core 6.0,How about openxml.package to handle Excel file?

    0 comments No comments

  3. Richie Mathison 0 Reputation points
    2024-05-01T15:04:18.05+00:00

    There is a warning message in here that is highlighted purple like the one that says we "Microsoft" does not support this check the product lifecycle. Have you seen that one? Well the other one I saw says it does not work because of the 64-bit conversion and 2019 was the last edition that worked. 2022 is 64-bit so it said the use the ACE. It really has no code sample that I could find so I asked a separate question.

    https://learn.microsoft.com/en-us/answers/questions/1662019/64-bit-conversion-explanation-what-to-do-now

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.