Windows 11 Drucker auslesen

Deutschsprachiges X#-Forum – German language forum

Moderator: wriedmann

Tudorf
Posts: 50
Joined: Wed Feb 08, 2023 3:43 pm

Re: Windows 11 Drucker auslesen

Post by Tudorf »

Hallo

Ich habe das Beispiel von Jamal bei mir eingespiel und habe lauter Fehler:

error XS0118: 'printDialog' is a variable but is used like a type
error XS0246: The type or namespace name 'DialogResult' could not be found (are you missing a using directive or an assembly reference?)
error XS0118: 'printDialog' is a variable but is used like a type
error XS0246: The type or namespace name 'DialogResult' could not be found (are you missing a using directive or an assembly reference?)
error XS0246: The type or namespace name 'MessageBox' could not be found (are you missing a using directive or an assembly reference?)
error XS0118: 'printDialog' is a variable but is used like a type
error XS0118: 'printDialog' is a variable but is used like a type
error XS0246: The type or namespace name 'DialogResult' could not be found (are you missing a using directive or an assembly reference?)
error XS0246: The type or namespace name 'MessageBox' could not be found (are you missing a using directive or an assembly reference?)

Muss ich noch was einbinden?

Martin
User avatar
Chris
Posts: 5630
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Re: Windows 11 Drucker auslesen

Post by Chris »

Hi Martin,

It's because the local name and the type name are the same. Please declare and use the LOCAL with another name, for example LOCAL printDlg AS printDialog. For the DialogResult and MessageBox, those are types defined in System.Windows.Forms.dll, please add a (GAC) reference to it and also add a USING System.Windows.Forms in the beginning of your prg.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
Jamal
Posts: 360
Joined: Mon Jul 03, 2017 7:02 pm

Re: Windows 11 Drucker auslesen

Post by Jamal »

Martin,

You need to include on top of the Form prg:

Code: Select all

USING System.Windows.Forms
USING System.Drawing.Printing
Let me know if need a full example as X# Visual Studio solution.
Last edited by Jamal on Thu May 22, 2025 7:32 pm, edited 1 time in total.
Tudorf
Posts: 50
Joined: Wed Feb 08, 2023 3:43 pm

Re: Windows 11 Drucker auslesen

Post by Tudorf »

Hallo

Ich habe jetzt noch einen Fehler.

Inzwischen habe ich diverse andere Files hinzugefügt. Leider ohne den Fehler weg zu bekommen.
USING System.Drawing.Printing
USING System.Windows.Forms
USING System.Windows.Forms.Design
USING System.Windows.Forms.Layout
USING System.Windows.Forms.VisualStyles
USING System.Windows.Forms.PropertyGridInternal
USING System.Windows.Forms.ComponentModel
USING System.Windows.Forms.ComponentModel.Com2Interop
USING System.Windows.Forms.Automation
USING System.Resources

Eigenlich hatte ich irgendwo System.Windows.Forms.CommonDialog erwartet, aber es gibt nichts.
20250522_105648.jpg
Ich habe absolut keine Ahnung wie da irgendwas zusammen hängen soll.

Danke Martin
User avatar
Chris
Posts: 5630
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Re: Windows 11 Drucker auslesen

Post by Chris »

Hi Martin,

The compiler reports this error on line 40, please show us this line of code.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
User avatar
wriedmann
Posts: 4079
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Re: Windows 11 Drucker auslesen

Post by wriedmann »

Hallo Martin,
wie was zusammenhängt:
https://docs.xsharp.it/doku.php?id=name ... _reference
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Tudorf
Posts: 50
Joined: Wed Feb 08, 2023 3:43 pm

Re: Windows 11 Drucker auslesen

Post by Tudorf »

Hallo

Danke Chris. Es läuft. Ich hatte einen Tippfehler.

Danke Worlfgang. ich habe mal da durchgeblättert. Der Aufbau mit den namen ist mir klar. Ansonnsten verstehe ich nur Bahnhof <s>. Da ich mit der Hilfe von Chris mein alte VO Programm nach X# gebracht habe, brauche ich mich in meinem Alten nicht mit .Net beschäftigen. Glücklicherweise schreibe ich ja nur für meine eigene Firma.

Martin
Post Reply