sungaila / PDFtoImage

A .NET library to render PDF files into images.
https://www.sungaila.de/PDFtoImage/
MIT License
152 stars 15 forks source link

Fix release build #1

Closed capnmidnight closed 3 years ago

capnmidnight commented 3 years ago

Builds that don't emit PDBs cannot have sources embedded.

sungaila commented 3 years ago

Hi @capnmidnight,

thanks for creating a pull request! Could you please elaborate on the issue with embedded sources?

Both Debug and Release builds produce PDB files (otherwise the NuGet symbol package would be emtpy) and it looks like the source code is embedded successfully. Is there something broken I did not notice?

Other than that I will not remove the target frameworks .NET Framework 4.6.1 and .NET Core 3.0. These are needed for legacy projects that cannot consume .NET 5.0 libraries. Feel free to remove them in your fork but I can't merge this into my repo. 😅

capnmidnight commented 3 years ago

Cripes, I'm sorry. I forgot that Github pull requests follow a branch and not the hash that was tip at the point the PR was made. That really obscured what I was doing.

Currently, I can't run the Release build of PDFtoImage as it stands in NuGet. Debug mode works, but Release mode kicks the sort of confusingly non-descript Access Violation exception I've found to be typical of GDI+ throwing up its hands when any sort of error occurs. You know, that "Attempted to read or write protected memory. This is often an indication that other memory is corrupt" jank that doesn't have any inner exception details or anything.

I tried to build against the source and had the same issue and got a compiler error saying the /embed flag could only be used when emitting PDBs. Again, only in Release mode.

So I disabled source embedding for Release build in my local build and could get past the compiler error, but then I now still had the same Access Violation exception. I ultimately had to configure my Solution to use the Debug build.

This was the case on both Windows and Linux. I'm running .NET 5.0 on both.

I'll close this PR, but maybe you know what might be going on with the compiler error?

EDIT: oh, that's particularly weird. I only get this error now when running with IIS Express. Running with Kestrel shows no issue.

sungaila commented 3 years ago

@capnmidnight Could you please open an issue if you can reproduce this bug reliably?

Somebody else found a System.AccessViolationException before and there might be more problems I am not aware of. You tested with PDFtoImage 1.1.0, right?

PDFtoImage uses the native library pdfium via interop. If something goes wrong in this unmanged lib, then you won't receive any helpful error messages.

Edit: Can't help with the compiler issue. I use Visual Studio 2019, which uses msbuild internally, for compiling and haven't had this /embed flag error yet.