BUG: PrinterSettings.ToString()

J

Jochen Kalmbach

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(ITypeDescriptorContext
context, CultureInfo culture, Object value, Type destinationType)
at System.ComponentModel.TypeConverter.ConvertToString(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
 
J

Jeffrey Tan[MSFT]

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 <[email protected]>
| Message-ID: <[email protected]>
| 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!TK2MSFTNGP12.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(ITypeDescriptorContext
| context, CultureInfo culture, Object value, Type destinationType)
| at System.ComponentModel.TypeConverter.ConvertToString(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
|
 
J

Jochen Kalmbach

Jeffrey said:
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(ITypeDescriptorContext
| context, CultureInfo culture, Object value, Type
| destinationType)
| at System.ComponentModel.TypeConverter.ConvertToString(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
 
J

Jeffrey Tan[MSFT]

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 <[email protected]>
| References: <[email protected]>
<[email protected]>
| Message-ID: <[email protected]>
| 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!TK2MSFTNGXA05.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(ITypeDescriptorContext
| >| context, CultureInfo culture, Object value, Type
| >| destinationType)
| >| at System.ComponentModel.TypeConverter.ConvertToString(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
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top