Has the EnableVisualStyles bug hit me?

S

Saurabh

Hello All,

I have a .NET application running on Windows XP. I have quite a few forms,
some modal and some modeless. Once in a while we get a wierd exception in
the application and most of the time the code is transferred to the top
level 'ThreadExceptionEventHandler'. It is difficult to get the information
on actual exception. Most of the time it seems to say "External component
has thrown an exception' and the source of the exception object is 'System'

Doing a bit of searching on the internet, I came across the known bug in
EnableVisualStyles( ). I do not call the Application.EnableVisualStyles at
all. but I do call Application.DoEvents (this was suggested as a fix
somewhere) I tried looking for the comctl32.dll. In the System32 folder the
dll has version 5.82. One of the articles on the internet said, XP uses 6.0
by default. Where would this dll be?

I do get rounded corners for my form's title bar, does this mean that my
application is using visual style? If yes where is it getting set? Is it the
default under Windows XP (SP2)?

Can somebody direct me to information which will lead to better
understanding of visual styles and the related bug. I don't even know
whether what I am facing is the same bug or not

TIA,

--Saurabh
 
D

Dmytro Lapshyn [MVP]

Hello,

Visual styles, when enabled, make your buttons, text boxes etc. look
XP-like. On the other hand, you get the 'rounded corners' even without
enabling visual styles.

According to my colleague, calling EnableVisualStyles indeed can cause some
nasty bug, but as you say you don't call this method, you should be on the
safe side.

Speaking of comctl32.dll version, it's 5.82.2900.2180 on my WinXP SP2
machine.

Here's what you can try. Attach event handlers to the
Application.ThreadException event and to the AppDomain.UnhandledException
event. Write some dummy code in the handlers just to have an ability to set
the breakpoint there. Once the breakpoint is hit, examine the exception
caught in the Watch window, paying special attention to the stack trace.
This way, you might get a clue on what is the actual source of the
exception.
 
S

Saurabh

Thanks for the help.

The thing that you mentioned is exactly what I had tried and thats where I
got the exception message as 'External component has thrown an exception'
with the source as 'System'.

The stack trace, most of the times look like :
at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd,
Int32 nCmdShow)
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)

Any more help is appreciated,

--Saurabh

Dmytro Lapshyn said:
Hello,

Visual styles, when enabled, make your buttons, text boxes etc. look
XP-like. On the other hand, you get the 'rounded corners' even without
enabling visual styles.

According to my colleague, calling EnableVisualStyles indeed can cause
some nasty bug, but as you say you don't call this method, you should be
on the safe side.

Speaking of comctl32.dll version, it's 5.82.2900.2180 on my WinXP SP2
machine.

Here's what you can try. Attach event handlers to the
Application.ThreadException event and to the AppDomain.UnhandledException
event. Write some dummy code in the handlers just to have an ability to
set the breakpoint there. Once the breakpoint is hit, examine the
exception caught in the Watch window, paying special attention to the
stack trace. This way, you might get a clue on what is the actual source
of the exception.

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]


Saurabh said:
Hello All,

I have a .NET application running on Windows XP. I have quite a few
forms, some modal and some modeless. Once in a while we get a wierd
exception in the application and most of the time the code is transferred
to the top level 'ThreadExceptionEventHandler'. It is difficult to get
the information on actual exception. Most of the time it seems to say
"External component has thrown an exception' and the source of the
exception object is 'System'

Doing a bit of searching on the internet, I came across the known bug in
EnableVisualStyles( ). I do not call the Application.EnableVisualStyles
at all. but I do call Application.DoEvents (this was suggested as a fix
somewhere) I tried looking for the comctl32.dll. In the System32 folder
the dll has version 5.82. One of the articles on the internet said, XP
uses 6.0 by default. Where would this dll be?

I do get rounded corners for my form's title bar, does this mean that my
application is using visual style? If yes where is it getting set? Is it
the default under Windows XP (SP2)?

Can somebody direct me to information which will lead to better
understanding of visual styles and the related bug. I don't even know
whether what I am facing is the same bug or not

TIA,

--Saurabh
 
S

Saurabh

I tried adding the call to EnableVisualStyles in my application and that did
make the app look different, I would assume that the visual styles are not
enabled on my machine so the exception that I am seeing is something else.

Also noticed, when I eneabled the visual styles, none of my tree nodes
displayed icons. Now thats the mentioned symptom of the bug. So no visual
styles for now.....

--Saurabh

Dmytro Lapshyn said:
Hello,

Visual styles, when enabled, make your buttons, text boxes etc. look
XP-like. On the other hand, you get the 'rounded corners' even without
enabling visual styles.

According to my colleague, calling EnableVisualStyles indeed can cause
some nasty bug, but as you say you don't call this method, you should be
on the safe side.

Speaking of comctl32.dll version, it's 5.82.2900.2180 on my WinXP SP2
machine.

Here's what you can try. Attach event handlers to the
Application.ThreadException event and to the AppDomain.UnhandledException
event. Write some dummy code in the handlers just to have an ability to
set the breakpoint there. Once the breakpoint is hit, examine the
exception caught in the Watch window, paying special attention to the
stack trace. This way, you might get a clue on what is the actual source
of the exception.

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]


Saurabh said:
Hello All,

I have a .NET application running on Windows XP. I have quite a few
forms, some modal and some modeless. Once in a while we get a wierd
exception in the application and most of the time the code is transferred
to the top level 'ThreadExceptionEventHandler'. It is difficult to get
the information on actual exception. Most of the time it seems to say
"External component has thrown an exception' and the source of the
exception object is 'System'

Doing a bit of searching on the internet, I came across the known bug in
EnableVisualStyles( ). I do not call the Application.EnableVisualStyles
at all. but I do call Application.DoEvents (this was suggested as a fix
somewhere) I tried looking for the comctl32.dll. In the System32 folder
the dll has version 5.82. One of the articles on the internet said, XP
uses 6.0 by default. Where would this dll be?

I do get rounded corners for my form's title bar, does this mean that my
application is using visual style? If yes where is it getting set? Is it
the default under Windows XP (SP2)?

Can somebody direct me to information which will lead to better
understanding of visual styles and the related bug. I don't even know
whether what I am facing is the same bug or not

TIA,

--Saurabh
 
M

Mick Doherty

What happens if you remove the call to DoEvents() and what did this
suggested fix cure?

Instead of calling Application.EnableVisualStyles and Application.DoEvents,
add a manifest file/resource and you will find that the images will display
in toolbars, listviews, etc..

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html


Saurabh said:
I tried adding the call to EnableVisualStyles in my application and that
did make the app look different, I would assume that the visual styles are
not enabled on my machine so the exception that I am seeing is something
else.

Also noticed, when I eneabled the visual styles, none of my tree nodes
displayed icons. Now thats the mentioned symptom of the bug. So no visual
styles for now.....

--Saurabh

Dmytro Lapshyn said:
Hello,

Visual styles, when enabled, make your buttons, text boxes etc. look
XP-like. On the other hand, you get the 'rounded corners' even without
enabling visual styles.

According to my colleague, calling EnableVisualStyles indeed can cause
some nasty bug, but as you say you don't call this method, you should be
on the safe side.

Speaking of comctl32.dll version, it's 5.82.2900.2180 on my WinXP SP2
machine.

Here's what you can try. Attach event handlers to the
Application.ThreadException event and to the AppDomain.UnhandledException
event. Write some dummy code in the handlers just to have an ability to
set the breakpoint there. Once the breakpoint is hit, examine the
exception caught in the Watch window, paying special attention to the
stack trace. This way, you might get a clue on what is the actual source
of the exception.

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]


Saurabh said:
Hello All,

I have a .NET application running on Windows XP. I have quite a few
forms, some modal and some modeless. Once in a while we get a wierd
exception in the application and most of the time the code is
transferred to the top level 'ThreadExceptionEventHandler'. It is
difficult to get the information on actual exception. Most of the time
it seems to say "External component has thrown an exception' and the
source of the exception object is 'System'

Doing a bit of searching on the internet, I came across the known bug in
EnableVisualStyles( ). I do not call the Application.EnableVisualStyles
at all. but I do call Application.DoEvents (this was suggested as a fix
somewhere) I tried looking for the comctl32.dll. In the System32 folder
the dll has version 5.82. One of the articles on the internet said, XP
uses 6.0 by default. Where would this dll be?

I do get rounded corners for my form's title bar, does this mean that my
application is using visual style? If yes where is it getting set? Is it
the default under Windows XP (SP2)?

Can somebody direct me to information which will lead to better
understanding of visual styles and the related bug. I don't even know
whether what I am facing is the same bug or not

TIA,

--Saurabh
 
D

Dmytro Lapshyn [MVP]

Application.DoEvents actually has nothing to do with visual styles. However,
it can cause problems, but of a very specific nature. The keyword is
re-rentrancy; in other word, if you are in an event handler and call
Application.DoEvents, your handler might be invoked recursively, causing
unpredictable results. Therefore, one who uses DoEvents might exercise
extreme caution to prevent re-entrancy and the unpredictable order of UI
events.

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]


"Mick Doherty"
What happens if you remove the call to DoEvents() and what did this
suggested fix cure?

Instead of calling Application.EnableVisualStyles and
Application.DoEvents, add a manifest file/resource and you will find that
the images will display in toolbars, listviews, etc..

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html


Saurabh said:
I tried adding the call to EnableVisualStyles in my application and that
did make the app look different, I would assume that the visual styles are
not enabled on my machine so the exception that I am seeing is something
else.

Also noticed, when I eneabled the visual styles, none of my tree nodes
displayed icons. Now thats the mentioned symptom of the bug. So no visual
styles for now.....

--Saurabh

Dmytro Lapshyn said:
Hello,

Visual styles, when enabled, make your buttons, text boxes etc. look
XP-like. On the other hand, you get the 'rounded corners' even without
enabling visual styles.

According to my colleague, calling EnableVisualStyles indeed can cause
some nasty bug, but as you say you don't call this method, you should be
on the safe side.

Speaking of comctl32.dll version, it's 5.82.2900.2180 on my WinXP SP2
machine.

Here's what you can try. Attach event handlers to the
Application.ThreadException event and to the
AppDomain.UnhandledException event. Write some dummy code in the
handlers just to have an ability to set the breakpoint there. Once the
breakpoint is hit, examine the exception caught in the Watch window,
paying special attention to the stack trace. This way, you might get a
clue on what is the actual source of the exception.

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]


Hello All,

I have a .NET application running on Windows XP. I have quite a few
forms, some modal and some modeless. Once in a while we get a wierd
exception in the application and most of the time the code is
transferred to the top level 'ThreadExceptionEventHandler'. It is
difficult to get the information on actual exception. Most of the time
it seems to say "External component has thrown an exception' and the
source of the exception object is 'System'

Doing a bit of searching on the internet, I came across the known bug
in EnableVisualStyles( ). I do not call the
Application.EnableVisualStyles at all. but I do call
Application.DoEvents (this was suggested as a fix somewhere) I tried
looking for the comctl32.dll. In the System32 folder the dll has
version 5.82. One of the articles on the internet said, XP uses 6.0 by
default. Where would this dll be?

I do get rounded corners for my form's title bar, does this mean that
my application is using visual style? If yes where is it getting set?
Is it the default under Windows XP (SP2)?

Can somebody direct me to information which will lead to better
understanding of visual styles and the related bug. I don't even know
whether what I am facing is the same bug or not

TIA,

--Saurabh
 

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