简体   繁体   English

.NET Core System.Drawing.Common PrintDocument在Linux上不起作用

[英].NET Core System.Drawing.Common PrintDocument doesn't work on Linux

I have a problem with PrintDocument from System.Drawing.Common when I use this on Linux, to be more specific, the problem comes from PrintingServices.LoadPrinterSettings, which is using in PrinterSettings.Unix 在Linux上使用System.Drawing.Common时,我在使用PrintDocument时遇到问题,更具体地说,问题出在PrinterSettings.Unix中使用的PrintingServices.LoadPrinterSettings。

here the content of the error: 这里的错误内容:

Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1] Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware [1]
An unhandled exception has occurred while executing the request. 执行请求时发生未处理的异常。 System.NullReferenceException: Object reference not set to an instance of an object. System.NullReferenceException:对象引用未设置为对象的实例。 at System.Drawing.Printing.PrintingServices.LoadPrinterSettings(String printer, PrinterSettings settings) 在System.Drawing.Printing.PrintingServices.LoadPrinterSettings处(字符串打印机,PrinterSettings设置)

On Windows everything working correctly, because PrintDocument uses solution prepare for Windows. 在Windows上,一切正常,因为PrintDocument使用解决方案为Windows做准备。

Code: 码:

PrintDocument pd = new PrintDocument();
pd.PrinterSettings.PrinterName = printerName;
pd.OriginAtMargins = true;
pd.DefaultPageSettings.Landscape = true;
pd.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0);
pd.PrintPage += new PrintPageEventHandler(Pd_PrintPage);
pd.Print();

I'm using: 我正在使用:

System.Drawing.common (4.5.1) System.Drawing.common(4.5.1)

.NET Core 2.1 .NET Core 2.1

libc6-dev and libgdiplus have been installed on Linux libc6-dev和libgdiplus已安装在Linux上

Linux - Debian 9 Linux-Debian 9

Anyone can help? 有人可以帮忙吗?

This is most likely an issue in System.Drawing.Common. 这很可能是System.Drawing.Common中的问题。 The printing code on Linux has been ported from Mono and hasn't received a lot of attention. Linux上的打印代码已从Mono移植而来,并没有引起太多关注。

If you can create a 'minimal repo', I think the best option is to file an issue at https://github.com/dotnet/corefx (or even better, send a PR). 如果您可以创建一个“最小存储库”,我认为最好的选择是在https://github.com/dotnet/corefx上提交问题(或者甚至更好,发送PR)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我应该安装哪些库才能在基于 Alpine 的图像中的 ASP NET Core 应用程序中使用 System.Drawing.Common - Which libraries should I install for work with System.Drawing.Common in ASP NET Core application inside Alpine-based image System.Drawing.Common DrawString 无法在 Linux 中正确呈现文本 - System.Drawing.Common DrawString not rendering text properly in Linux IronPDF 对 System.Drawing.Common 的依赖 - IronPDF dependency on System.Drawing.Common System.Drawing.Common 不适用于 Windows - System.Drawing.Common not working on Windows 使用 C#.net5.0 但没有 System.Drawing.Common 获取/设置图像文件的分辨率? - Get/set the resolution of an image file using C# net5.0 but without System.Drawing.Common? .NET System.Drawing.Common 4.5.1 的 NuGet 包包含不正确的程序集版本 - NuGet package for .NET System.Drawing.Common 4.5.1 contains incorrect version of assemblies 错误 NU1100:无法为“net6.0”解析“HtmlAgilityPack (>= 1.11.45)”和“System.Drawing.Common (>= 6.0.0)” - error NU1100: Unable to resolve 'HtmlAgilityPack (>= 1.11.45)' and 'System.Drawing.Common (>= 6.0.0)' for 'net6.0' .NET 6/7 从 System.Drawing.Common 迁移到 Microsoft.Maui.Graphics - .NET 6/7 Migration from System.Drawing.Common to Microsoft.Maui.Graphics 无法在 DLL 的类中加载依赖项 system.drawing.common - Cannot load dependency system.drawing.common in a class in a DLL System.drawing.common 'gdip' 的类型初始值设定项抛出异常 - System.drawing.common the type initializer for 'gdip' threw an exception
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM