简体   繁体   中英

MigraDoc and .NET Core 2.0

I have made a class library for PDF-generation. It is implemented using PDFshart-MigraDoc (the core package*). The class library itself is made with .NET Standard as its target framework.

I can use the class library in classic C# projects (like WinForms), but if I try to use it with .NET Core 2.0, I get the following error:

Could not load file or assembly 'System.Drawing.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=xxxx'. The system cannot find the file specified.

I guess the reason for this, could be that MigraDoc is using 'System.Drawing' in its implementation, which is (as far as I know) not supported by the .NET Core framework.

However, that doesn't really solve my problem, which is that I need the class library to work for all .NET frameworks. I have tried to include the NuGet package CoreCompat.System.Drawing , based on advise from this post . But this has been without effect, probably because MigraDoc is still trying to use the "original" System.Drawing library.

Is there any way, in which I can get my class library to work for .NET Core? Or am I out of luck...?

Note: The MigraDoc Core Package has nothing to do with the .NET Core Framework. The clash of names is merely a coincidence.

I found a port for PDFSharp & MigraDoc here on github which uses System.Drawing.Common and works with .Net Core.

I had the same and got it fully working.

Note: You may need to add System.Drawing.Common Nuget Package in your .Net Core project.

The MigraDoc/PDFsharp Core packages were created long before .NET Core was even announced. "Core" has a different meaning for those MigraDoc packages and they do use System.Drawing.

It's not a bug that the Core package uses System.Drawing.

There are third-party ports of PDFsharp for .NET Core like this one:
https://github.com/groege/PdfSharpCore
Maybe one of these ports is an option for you.

Maybe there are portable replacements for System.Drawing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM