Problem with Microsoft.Office.Interop.Excel and .net8

After a long time, I have a problem again.

I have a DLL project that was previously created for .net Framework 4.8. It uses the Microsoft.Office.Interop.Excel package.

After converting the project to .net8, it no longer works. The package is included (entry in the .elements file exists), but is not displayed in the project solution. When compiling, the error message
(E28) Unknown type “Microsoft.Office.Interop.Excel.Application”
appears.

However, a .net8 test project with C# compiles without any problems and the package is also listed in the project solution.

I use Visual Studio 2022.

The attached ZIP file contains three test projects (Oxygene .net4, Oxygene .net8 and C# .net8).

Best regards,
Manfred

Interop_Excel_Error.zip (5.1 MB)

You need to change the reference to a proper NuGet package reference:

    <NuGetReference Include="Microsoft.Office.Interop.Excel:15.0.4795.1001">
      <Private>True</Private>
    </NuGetReference>

This will work on 4.8 and .NET Core. On .NET Core, we ignore DLL references that start with System. or Microsoft., as these should all come from NuGet.

1 Like

Hello Marc

Thank you, it works now.

1 Like

Happy to hear!