By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,301 Members | 3,575 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,301 IT Pros & Developers. It's quick & easy.

BUG: PrinterSettings.ToString()

P: n/a
Hello,

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

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

at System.ComponentModel.EnumConverter.ConvertTo(ITyp eDescriptorContext
context, CultureInfo culture, Object value, Type destinationType)
at System.ComponentModel.TypeConverter.ConvertToStrin g(Object value)
at System.Drawing.Printing.PrinterSettings.ToString()
at PrinterSettingsBug_CS.Class1.Main(String[] args)
Here is a simple example to reproduce the problem:

<code>
namespace PrinterSettingsBug_CS
{
class Class1
{
[System.STAThread]
static void Main(string[] args)
{
System.Drawing.Printing.PrinterSettings ps = new
System.Drawing.Printing.PrinterSettings();

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

--
Greetings
Jochen

Do you need a memory-leak finder ?
http://www.codeproject.com/tools/leakfinder.asp
Nov 15 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

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"CujilO8C4^r,6rco%?.Xk?;y`M?j&$Pmm>%[c!9kDW7m]C~N
bWutCC$vPTUW-"icn`nX:[F"N;mB9}]ABU?Y]tZwmSP{]!
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Date: Wed, 17 Sep 2003 05:41:41 -0700
| NNTP-Posting-Host: 217.7.150.245
| Lines: 1
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP12.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:185455
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Hello,
|
| if an PrinterSettings-Instance is not set-up correctly (for example just
| by using the default-constructor), then the "ToString()"_method will
| throw an exception!
|
|
|
| Unhandled Exception: System.ArgumentException: The value '0' is not a
| valid value for the enum 'Duplex'.
|
| at System.ComponentModel.EnumConverter.ConvertTo(ITyp eDescriptorContext
| context, CultureInfo culture, Object value, Type destinationType)
| at System.ComponentModel.TypeConverter.ConvertToStrin g(Object value)
| at System.Drawing.Printing.PrinterSettings.ToString()
| at PrinterSettingsBug_CS.Class1.Main(String[] args)
|
|
| Here is a simple example to reproduce the problem:
|
| <code>
| namespace PrinterSettingsBug_CS
| {
| class Class1
| {
| [System.STAThread]
| static void Main(string[] args)
| {
| System.Drawing.Printing.PrinterSettings ps = new
| System.Drawing.Printing.PrinterSettings();
|
| System.Console.WriteLine(ps.ToString()); // <===== Exception *****

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

Nov 15 '05 #2

P: n/a
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.ArgumentException: The value '0' is not a
| valid value for the enum 'Duplex'.
|
| at
| System.ComponentModel.EnumConverter.ConvertTo(ITyp eDescriptorContext
| context, CultureInfo culture, Object value, Type
| destinationType)
| at System.ComponentModel.TypeConverter.ConvertToStrin g(Object
| value) at System.Drawing.Printing.PrinterSettings.ToString()
| at PrinterSettingsBug_CS.Class1.Main(String[] args)
|
|
| Here is a simple example to reproduce the problem:
|
| <code>
| namespace PrinterSettingsBug_CS
| {
| class Class1
| {
| [System.STAThread]
| static void Main(string[] args)
| {
| System.Drawing.Printing.PrinterSettings ps = new
| System.Drawing.Printing.PrinterSettings();
|
| System.Console.WriteLine(ps.ToString()); // <===== Exception
| *****

| }
| }
| }
| </code>


--
Greetings
Jochen

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

P: n/a

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"CujilO8C4^r,6rco%?.Xk?;y`M?j&$Pmm>%[c!9kDW7m]C~N
bWutCC$vPTUW-"icn`nX:[F"N;mB9}]ABU?Y]tZwmSP{]!
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Date: Wed, 17 Sep 2003 22:59:37 -0700
| NNTP-Posting-Host: 217.7.150.245
| Lines: 1
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGXA06.phx.gbl!TK2MSFT NGXA05.phx.gbl!TK2MSFTNGP0
8.phx.gbl!TK2MSFTNGP11.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:185706
| X-Tomcat-NG: microsoft.public.dotnet.languages.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.ArgumentException: The value '0' is not a
| >| valid value for the enum 'Duplex'.
| >|
| >| at
| >| System.ComponentModel.EnumConverter.ConvertTo(ITyp eDescriptorContext
| >| context, CultureInfo culture, Object value, Type
| >| destinationType)
| >| at System.ComponentModel.TypeConverter.ConvertToStrin g(Object
| >| value) at System.Drawing.Printing.PrinterSettings.ToString()
| >| at PrinterSettingsBug_CS.Class1.Main(String[] args)
| >|
| >|
| >| Here is a simple example to reproduce the problem:
| >|
| >| <code>
| >| namespace PrinterSettingsBug_CS
| >| {
| >| class Class1
| >| {
| >| [System.STAThread]
| >| static void Main(string[] args)
| >| {
| >| System.Drawing.Printing.PrinterSettings ps = new
| >| System.Drawing.Printing.PrinterSettings();
| >|
| >| System.Console.WriteLine(ps.ToString()); // <===== Exception
| >| *****
| >
| >| }
| >| }
| >| }
| >| </code>
|
| --
| Greetings
| Jochen
|
| Do you need a memory-leak finder ?
| http://www.codeproject.com/tools/leakfinder.asp
|

Nov 15 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.