Skip to content

bugfix/macOSGraphicsFromHwndSystemNotSupportedException: System.NotSupportedException: Specified method is not supported.#133

Merged
marcosgerene merged 1 commit into
Hercules-NET:masterfrom
eneiasramos:bugfix/macOSGraphicsFromHwndSystemNotSupportedException
Dec 11, 2025
Merged

bugfix/macOSGraphicsFromHwndSystemNotSupportedException: System.NotSupportedException: Specified method is not supported.#133
marcosgerene merged 1 commit into
Hercules-NET:masterfrom
eneiasramos:bugfix/macOSGraphicsFromHwndSystemNotSupportedException

Conversation

@eneiasramos

Copy link
Copy Markdown
Contributor

Adicionado rotina que substitui Graphics.FromHwnd() do Windows para Graphics.FromImage() no Unix ( macOS, FreeBSD, Linux ) e corrigir o exception ( System.NotSupportedException: Specified method is not supported. ) no metodo MedidasLinha.GetMedidas() em NFe.Danfe.Nativo/GraphicsPrinter/MedidasLinha.cs

…otina que substitui Graphics.FromHwnd() do Windows para Graphics.FromImage() no Unix ( macOS, FreeBSD, Linux ) e corrigir o exception ( System.NotSupportedException: Specified method is not supported. ) no metodo MedidasLinha.GetMedidas() em NFe.Danfe.Nativo/GraphicsPrinter/MedidasLinha.cs
@eneiasramos eneiasramos force-pushed the bugfix/macOSGraphicsFromHwndSystemNotSupportedException branch from db537dc to c6bc6ab Compare December 10, 2025 14:00
@eneiasramos

Copy link
Copy Markdown
Contributor Author

Caros, segue trace do exception para ajudar no review:

Message: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NotSupportedException: Specified method is not supported.
at System.Drawing.MacSupport.GetCGContextForView (System.IntPtr handle) [0x0001a] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/mcs/class/System.Drawing/System.Drawing/macFunctions.cs:112
at System.Drawing.Graphics.FromHwnd (System.IntPtr hwnd) [0x00055] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/mcs/class/System.Drawing/System.Drawing/Graphics.cs:1746
at NFe.Danfe.Nativo.GraphicsPrinter.MedidasLinha.GetMedidas (System.String texto, System.Drawing.Font fonte) [0x00001] in :0
at NFe.Danfe.Nativo.GraphicsPrinter.MedidasLinha.GetMedidas (NFe.Danfe.Nativo.GraphicsPrinter.AdicionarTexto adicionarTexto) [0x0000d] in :0
at NFe.Danfe.Nativo.GraphicsPrinter.AdicionarTexto..ctor (System.Drawing.Graphics graphics, System.String texto, System.Int32 tamanhoFonte, System.Drawing.SolidBrush br, System.Drawing.Font font) [0x0005e] in :0
at NFe.Danfe.Nativo.NFCe.DanfeNativoNfce.EscreverLinhaTitulo (System.Drawing.Graphics g, System.String texto, System.Int32 tamanhoFonteTitulo, System.Int32 larguraLogo, System.Int32 x, System.Int32 y, System.Int32 larguraLinha) [0x00001] in :0
at NFe.Danfe.Nativo.NFCe.DanfeNativoNfce.GerarNfCe (System.Drawing.Graphics graphics) [0x00075] in :0
at NFe.Danfe.Nativo.NFCe.DanfeNativoNfce.printCupom_PrintPage (System.Object sender, System.Drawing.Printing.PrintPageEventArgs e) [0x00008] in :0
at System.Drawing.Printing.PrintDocument.OnPrintPage (System.Drawing.Printing.PrintPageEventArgs e) [0x00008] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/mcs/class/System.Drawing/System.Drawing.Printing/PrintDocument.cs:190
at System.Drawing.Printing.PrintDocument.Print () [0x000d2] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/mcs/class/System.Drawing/System.Drawing.Printing/PrintDocument.cs:159
at (wrapper remoting-invoke-with-check) System.Drawing.Printing.PrintDocument.Print()
at NFe.Danfe.Nativo.NFCe.DanfeNativoNfce.Imprimir (System.String nomeImpressora, System.String salvarArquivoPdfEm) [0x0007b] in :0

@marcosgerene

Copy link
Copy Markdown
Collaborator

O funcionamento no Windows é afetado com sua mudança?

Eu referenciei o @robertorp porque ele fez a impressão nativa, se não me engano.

Eu não uso esse app nativo, não faço ideia de como funciona.

@eneiasramos

Copy link
Copy Markdown
Contributor Author

@marcosgerene não afeta o funcionamento do Windows meu caro 👍

@marcosgerene marcosgerene merged commit ee95bc7 into Hercules-NET:master Dec 11, 2025
@eneiasramos

Copy link
Copy Markdown
Contributor Author

@marcosgerene obrigado meu caro! 👍

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants