473,597 Members | 2,342 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

BUG: PrinterSettings .ToString()

Hello,

if an PrinterSettings-Instance is not set-up correctly (for example just
by using the default-constructor), then the "ToString()"_me thod will
throw an exception!

Unhandled Exception: System.Argument Exception: The value '0' is not a
valid value for the enum 'Duplex'.

at System.Componen tModel.EnumConv erter.ConvertTo (ITypeDescripto rContext
context, CultureInfo culture, Object value, Type destinationType )
at System.Componen tModel.TypeConv erter.ConvertTo String(Object value)
at System.Drawing. Printing.Printe rSettings.ToStr ing()
at PrinterSettings Bug_CS.Class1.M ain(String[] args)
Here is a simple example to reproduce the problem:

<code>
namespace PrinterSettings Bug_CS
{
class Class1
{
[System.STAThrea d]
static void Main(string[] args)
{
System.Drawing. Printing.Printe rSettings ps = new
System.Drawing. Printing.Printe rSettings();

System.Console. WriteLine(ps.To String()); // <===== Exception *****
}
}
}
</code>

--
Greetings
Jochen

Do you need a memory-leak finder ?
http://www.codeproject.com/tools/leakfinder.asp
Nov 15 '05 #1
3 2653

Hi Jochen,

What is the version of your VS.NET and .Net Framework?
I have tried your code, but no exception generated.
My VS.net IDE is 2003 Version 7.1.3088, .Net Framework is 1.1
Version 1.1.4322

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Subject: BUG: PrinterSettings .ToString()
| From: Jochen Kalmbach <no************ ********@holzma .de>
| Message-ID: <Xn************ *************** ******@127.0.0. 1>
| User-Agent: Xnews/5.04.25
| X-Face:
#TA[Jae"bdx-+QGJx=d8Gi"Cuji lO8C4^r,6rco%?. Xk?;y`M?j&$Pmm> %[c!9kDW7m]C~N
bWutCC$vPTUW-"icn`nX:[F"N;mB9}]ABU?Y]tZwmSP{]!
| Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
| Date: Wed, 17 Sep 2003 05:41:41 -0700
| NNTP-Posting-Host: 217.7.150.245
| Lines: 1
| Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP12.phx.g bl
| Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1854 55
| X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
|
| Hello,
|
| if an PrinterSettings-Instance is not set-up correctly (for example just
| by using the default-constructor), then the "ToString()"_me thod will
| throw an exception!
|
|
|
| Unhandled Exception: System.Argument Exception: The value '0' is not a
| valid value for the enum 'Duplex'.
|
| at System.Componen tModel.EnumConv erter.ConvertTo (ITypeDescripto rContext
| context, CultureInfo culture, Object value, Type destinationType )
| at System.Componen tModel.TypeConv erter.ConvertTo String(Object value)
| at System.Drawing. Printing.Printe rSettings.ToStr ing()
| at PrinterSettings Bug_CS.Class1.M ain(String[] args)
|
|
| Here is a simple example to reproduce the problem:
|
| <code>
| namespace PrinterSettings Bug_CS
| {
| class Class1
| {
| [System.STAThrea d]
| static void Main(string[] args)
| {
| System.Drawing. Printing.Printe rSettings ps = new
| System.Drawing. Printing.Printe rSettings();
|
| System.Console. WriteLine(ps.To String()); // <===== Exception *****

| }
| }
| }
| </code>
|
| --
| Greetings
| Jochen
|
| Do you need a memory-leak finder ?
| http://www.codeproject.com/tools/leakfinder.asp
|

Nov 15 '05 #2
Jeffrey Tan[MSFT] wrote:
What is the version of your VS.NET and .Net Framework?
I have tried your code, but no exception generated.
My VS.net IDE is 2003 Version 7.1.3088, .Net Framework is 1.1
Version 1.1.4322
I have the same:
VS.NET IDE is 2003 Version 7.1.3088
..NET Frameworrk Version 1.1.4.4322

And the problem really happens...

Greetings
Jochen

| Unhandled Exception: System.Argument Exception: The value '0' is not a
| valid value for the enum 'Duplex'.
|
| at
| System.Componen tModel.EnumConv erter.ConvertTo (ITypeDescripto rContext
| context, CultureInfo culture, Object value, Type
| destinationType )
| at System.Componen tModel.TypeConv erter.ConvertTo String(Object
| value) at System.Drawing. Printing.Printe rSettings.ToStr ing()
| at PrinterSettings Bug_CS.Class1.M ain(String[] args)
|
|
| Here is a simple example to reproduce the problem:
|
| <code>
| namespace PrinterSettings Bug_CS
| {
| class Class1
| {
| [System.STAThrea d]
| static void Main(string[] args)
| {
| System.Drawing. Printing.Printe rSettings ps = new
| System.Drawing. Printing.Printe rSettings();
|
| System.Console. WriteLine(ps.To String()); // <===== Exception
| *****

| }
| }
| }
| </code>


--
Greetings
Jochen

Do you need a memory-leak finder ?
http://www.codeproject.com/tools/leakfinder.asp
Nov 15 '05 #3

Hi ,

Have you overrided the ToString method of PrinterSettings ?
If not, have you tried this code on other machines?

It is strange that I have tried your code on my 3 colleagues' machine and
all work well. (their VS.net also version 2003 Framework 1.1)

Best regards,
Beste
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Subject: RE: BUG: PrinterSettings .ToString()
| From: Jochen Kalmbach <no************ ********@holzma .de>
| References: <Xn************ *************** ******@127.0.0. 1>
<KY************ **@cpmsftngxa06 .phx.gbl>
| Message-ID: <Xn************ *************** ******@127.0.0. 1>
| User-Agent: Xnews/5.04.25
| X-Face:
#TA[Jae"bdx-+QGJx=d8Gi"Cuji lO8C4^r,6rco%?. Xk?;y`M?j&$Pmm> %[c!9kDW7m]C~N
bWutCC$vPTUW-"icn`nX:[F"N;mB9}]ABU?Y]tZwmSP{]!
| Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
| Date: Wed, 17 Sep 2003 22:59:37 -0700
| NNTP-Posting-Host: 217.7.150.245
| Lines: 1
| Path:
cpmsftngxa06.ph x.gbl!TK2MSFTNG XA06.phx.gbl!TK 2MSFTNGXA05.phx .gbl!TK2MSFTNGP 0
8.phx.gbl!TK2MS FTNGP11.phx.gbl
| Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1857 06
| X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
|
| Jeffrey Tan[MSFT] wrote:
|
| > What is the version of your VS.NET and .Net Framework?
| > I have tried your code, but no exception generated.
| > My VS.net IDE is 2003 Version 7.1.3088, .Net Framework is 1.1
| > Version 1.1.4322
|
| I have the same:
| VS.NET IDE is 2003 Version 7.1.3088
| .NET Frameworrk Version 1.1.4.4322
|
| And the problem really happens...
|
| Greetings
| Jochen
|
|
| >| Unhandled Exception: System.Argument Exception: The value '0' is not a
| >| valid value for the enum 'Duplex'.
| >|
| >| at
| >| System.Componen tModel.EnumConv erter.ConvertTo (ITypeDescripto rContext
| >| context, CultureInfo culture, Object value, Type
| >| destinationType )
| >| at System.Componen tModel.TypeConv erter.ConvertTo String(Object
| >| value) at System.Drawing. Printing.Printe rSettings.ToStr ing()
| >| at PrinterSettings Bug_CS.Class1.M ain(String[] args)
| >|
| >|
| >| Here is a simple example to reproduce the problem:
| >|
| >| <code>
| >| namespace PrinterSettings Bug_CS
| >| {
| >| class Class1
| >| {
| >| [System.STAThrea d]
| >| static void Main(string[] args)
| >| {
| >| System.Drawing. Printing.Printe rSettings ps = new
| >| System.Drawing. Printing.Printe rSettings();
| >|
| >| System.Console. WriteLine(ps.To String()); // <===== Exception
| >| *****
| >
| >| }
| >| }
| >| }
| >| </code>
|
| --
| Greetings
| Jochen
|
| Do you need a memory-leak finder ?
| http://www.codeproject.com/tools/leakfinder.asp
|

Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
705
by: RBisch | last post by:
I am finding that some of the properties off of the PrinterSettings object are misleading For example, When I test the CanDuplex on a printer I know duplexes, the property is false. Another one is DefaultPrinter, it is set to false when I know that I have that printer set as default (I verify via the "Printers and Fax" applet Can anyone confirm or explain TIA
3
4930
by: Steve Hanna | last post by:
I am having problems using the Printer Dialog to set PrinterSettings, specifically the landscape property of the DefaultPageSettings. Here's the code: <code> Private Sub GetPrinter(ByRef PrinterSettings as PrinterSettings, Landscape as Boolean) Dim pdiag As New PrintDialog Dim pset As New PrinterSettings pset.DefaultPageSettings.Landscape = Landscape
1
7752
by: Richard Golebiowski | last post by:
I have been trying to figure this out for quite some time and cannot find any examples in VB.Net or in VB that work correctly. I am working on an application where I want the user to be able to select a peinter and printer tray to print reports out. In Crystal Reports 8.5, I can select a printer and tray and it prints correctly. I did a test report that I use to tell me the value that Crystal Reports is using for the paper source. When I...
0
1398
by: Steph. | last post by:
Hi, Is there a BUG in the printdialog ? When I create a PrintDialog ans set the "DefaultPageSettings.Landscape" property to "false" and then display the dialog, select "Landscape" and click OK, the value of the "DefaultPageSettings.Landscape" is still false !!?? Code Exemple : PrintDialog PDialog = new PrintDialog(); PDialog.PrinterSettings = new System.Drawing.Printing.PrinterSettings();...
4
5381
by: Steph. | last post by:
Hi, Is there a BUG in the printdialog ? When I create a PrintDialog ans set the "DefaultPageSettings.Landscape" property to "false" and then display the dialog, select "Landscape" and click OK, the value of the "DefaultPageSettings.Landscape" is still false !!?? Code Exemple : PrintDialog PDialog = new PrintDialog(); PDialog.PrinterSettings = new System.Drawing.Printing.PrinterSettings();...
0
1552
by: trint | last post by:
try { // Wait for the report to completely render. if(m_numberOfPages < 1) return false; PrinterSettings printerSettings = new PrinterSettings(); printerSettings.MaximumPage = m_numberOfPages; printerSettings.MinimumPage = 1; printerSettings.PrintRange = PrintRange.SomePages; printerSettings.FromPage = 1;
1
1265
by: Babz | last post by:
Hi Using the PrinterSettings class I want to get the No. Of copies of the document to be printed. But it is always giving 1 as the copies to be printed. I am using following code dgPrintDialog.PrinterSettings.Copies = 2 dgPrintDialog.ShowDialog() NoOfCopies= dgPrintDialog.PrinterSettings.Copies What is wrong with this code. Most of the people have raised the same issue
2
6213
by: Tessa | last post by:
Hi, We have a .net web application, and are trying to use PrinterSettings.InstalledPrinters to list the printers installed on the webserver. (Windows 2003 server R2, IIS 6, .net framework 2.0.) The printers installed on the web server under the account used by asp.net for this web application are network printers that are shared by other computers that are on our domain. Permission has been granted for everyone to print to them. The...
2
5423
by: =?Utf-8?B?RGF2aWQ=?= | last post by:
I’m not sure how to feed PCL commands (i.e. “Ec&l1S”) thru the PrinterSettings() function, but we have been successfully using the PrinterSetting() properties and methods to successfully call on most of the printer’s properties. Our understanding was that by using the correct combination of “.Landscape” and “.Duplex.Horizontal” properties, we would be able to accomplish the “flip pages up”, in which the report is...
0
8272
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8035
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8258
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5847
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5431
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3886
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3927
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1494
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1238
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.