EvotecIT / OfficeIMO

Fast and easy to use cross-platform .NET library that creates or modifies Microsoft Word (DocX) and later also Excel (XLSX) files without installing any software. Library is based on Open XML SDK
MIT License
261 stars 47 forks source link

InvalidProgramException #186

Closed Goddfrey closed 6 months ago

Goddfrey commented 6 months ago

The line I copied directly from readme, throws an InvalidProgramException "Common Language Runtime detected an invalid program."

using (WordDocument document = WordDocument.Create(path)) // this line
{
    // some code
}

readme says "The main thing is - it has to work with .NET Framework 4.7.2, .NET Standard 2.0 and so on." so I assumed .NET 8.0 falls under "so on" ;) but I also tried to change my project's target framework to .NET 7.0 which is explicitly mentioned among dependencies, and it still throws the same exception. "Platform target" is "Any CPU" if that matters.

OfficeIMO.Word v 0.12.0 installed via VisualStudio nugget manager

PrzemyslawKlys commented 6 months ago

And what happens if you get the whole project and run examples?

Goddfrey commented 6 months ago

And what happens if you get the whole project and run examples?

There were some "file not found in C:/TEMP..." exceptions but when it comes to this particular issue, it seems to work perfectly fine.

PrzemyslawKlys commented 6 months ago

Then you're doing something wrong when setting up project. Maybe copy one of examples and try to use them outside?

tmpmachine commented 5 months ago

In my case, this one package was causing the issue. Uninstalling it solved the issue.

<PackageReference Include="DocumentFormat.OpenXml" Version="3.0.1" />
PrzemyslawKlys commented 5 months ago

ye, it's newer version than we support: