Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excel Interop, Could not load file or assembly #433

Open
tsiank opened this issue May 23, 2022 · 7 comments · May be fixed by #435
Open

Excel Interop, Could not load file or assembly #433

tsiank opened this issue May 23, 2022 · 7 comments · May be fixed by #435

Comments

@tsiank
Copy link

tsiank commented May 23, 2022

Describe the bug
I use Microsoft.Office.Interop.Excel.dll in RoslynPad15 DotNet 6.0 to read and write Excel, but it shows error:
"Could not load file or assembly 'office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'. "
But it can run normally with dotnetFrameWork
To Reproduce

Expected behavior

Version

  • OS:Windows 11
  • Build (or commit ID if built from source):RoslynPad15 and RoslynPad16
    20220523131611
@jboinembalome
Copy link
Contributor

Thank you for reporting this issue 👍

It seems that the problem is not with RoslynPad but with the Microsoft.Office.Interop.Excel DLL
Unfortunately, this DLL has not been updated to work with .NET 6
The latest framework compatible with Microsoft.Office.Interop.Excel is .NET 4.8

As an example, if we create a console application targeting .NET 6, we will get the same error:
image

@tsiank
Copy link
Author

tsiank commented May 27, 2022

Thank you for reporting this issue 👍

It seems that the problem is not with RoslynPad but with the Microsoft.Office.Interop.Excel DLL Unfortunately, this DLL has not been updated to work with .NET 6 The latest framework compatible with Microsoft.Office.Interop.Excel is .NET 4.8

As an example, if we create a console application targeting .NET 6, we will get the same error: image

Thank you for your reply.
This Microsoft.Office.Interop.Excel DLL can be used in LinqPad7 with DotNet6.0, and it works well, so I guess there are some tricks that can fix this bug.
LinqPad_20220528000413

@jboinembalome
Copy link
Contributor

Microsoft.Office.Interop.Excel targets .NET Standard 2.0. As a result, this DLL can work with .NET 6.0.
However, this DLL has not been updated to work with .NET Core by default.

If we take the example of the console application, it is necessary to import the DLL manually and to define the EmbedInteropTypes property.

Regarding LinqPad, indeed the developers have added the possibility to integrate the Office Interop COM libraries from the 6th version for .NET Core 3.1 and above.

So can we classify this issue as an enhancement?

I will try to work on it! 😉

@jboinembalome
Copy link
Contributor

@tsiank, I created a PR to solve this issue 👍
Thank you for your feedback!

@tsiank
Copy link
Author

tsiank commented May 28, 2022

@jboinembalome ,I have't thought it's fixed so quickly, thank you for your work, that's great! I will have a try.

@tsiank
Copy link
Author

tsiank commented May 28, 2022

@jboinembalome ,I have tested, it works perfectly now, thank you again!

@jboinembalome
Copy link
Contributor

Good news! You’re welcome @tsiank, it's a pleasure to help you 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants