AnthonyM
AnthonyM

Reputation: 1145

How to resolve file not found when loading interop dll with .net core 3.0?

I'm trying to port some code from .net frame 4.7.1 to .net core 3.0.

The problem is that we have a C++ COM assembly that we use a manifest to reference in out .net project.

I've added the project to the new solution and added the reference. An interop dll was created, but when I try to run the code I get an exception

{"Could not load file or assembly 'Interop.MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.":"Interop.MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"}

The file is in the output folder for the project. The actual com assembly wasn't, but even copying it in doesn't work.

Upvotes: 2

Views: 2478

Answers (2)

Dave ت Maher
Dave ت Maher

Reputation: 1731

EmbedInteropTypes!!! took me forever to find this...!!

<Reference Include="Microsoft.Office.Interop.Excel, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
  <HintPath>Microsoft.Office.Interop.Excel.dll</HintPath>
  <EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>

Upvotes: 0

AnthonyM
AnthonyM

Reputation: 1145

The answer turns out to be that adding a reference in visual studio doesn't work for .net core apps.

The solution is to create a .net framework app, add the reference, then copy the comreference sections of the csproj into your .net core project.

Upvotes: 2

Related Questions