Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8824209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:33:15+00:00 2026-06-14T06:33:15+00:00

I want to call a specific printer to print in my WPF application. I

  • 0

I want to call a specific printer to print in my WPF application.
I have three printer
Suppose
Printer1 for Bar bill Print
Printer2 for Kitchen bill Print
Printer3 for Guest bill Print
printers name already saved in database, while printing I get a printer name from DB
and want to print from specific printer, not defaul printer
Here is my code

var v = new PrinterDAL().GetPrinterSettings();
try
{
   System.Threading.Thread thread = new System.Threading.Thread(new 
      System.Threading.ThreadStart(
            delegate()
            {   
                gridPrint.Dispatcher.Invoke(DispatcherPriority.Normal,
                    new Action(
                    delegate()
                    {
                            PrintDialog printDialog = new PrintDialog();
                            printDialog.PrintQueue = new PrintQueue(
                                new PrintServer(@"\\" + v.BarPrinter), "");
                            printDialog.PrintVisual(gridPrint, "");
                            this.Close();
                    }
                ));
            }
            ));
            thread.Start();
}
catch (Exception ex)
{
     Xceed.Wpf.Toolkit.MessageBox.Show(ex.Message, "", MessageBoxButton.OK, 
                                       MessageBoxImage.Error);
}

I get an exception from this code

“An exception occurred while creating the PrintServer object. Win32 error: The printer name is invalid.”

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:33:17+00:00Added an answer on June 14, 2026 at 6:33 am

    PrintServer must be instance using a computer or printer server device in UNC format (\\resource) not a printer name:

    For example, if the name of your computer, in your domain, is KashifPC and you have configured a printer, called “Printer1”, you can use:

    //example code. no error handling.
    PrintServer localPS = New PrintServer(@"\\KashifPC")
    PrinterQueue printer1 = localPS.GetPrintQueue("Printer1") //v.BarPrinter???
    PrintDialog printDialog = new PrintDialog();
    printDialog.PrintQueue = printer1
    //rest of code
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to call a specific function on my C# application at a specific
I have a slider and I want to call a specific function only when
I want to call a function in my application on a specific time without
I want to call specific php function on server from Android application and also
I want to call a web service that requires an authentication cookie. I have
Depending on the subdomain I want to call a specific controller. What I currently
I am trying to create an application in which I want to call a
My app supports minSdkVersion=10 and targeting 16. I want to call methods specific to
Here's the deal: I have an Android application that needs to call a web
I want to call an external program from Python. I have used both Popen()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.