in

dotNetFreak

Ramblings & Controls from a .NET Addicted Freak!

Kevin Gearing's Blog

System.Runtime.InteropServices.SEHException

Argh! Just when my application was starting to look really good I come across the dreaded "System.Runtime.InteropServices.SEHException".

For those of you who don't know, this tends to happen if you make use of Application.EnableVisualStyles() to give your program the XP look 'n' feel, or in my case if you're using Skybounds excellent VisualStyles component (http://www.skybound.ca/developer/visualstyles/) and start opening Dialog windows.

Whilst removing Application.EnableVisualStyles() or using a Manifest file will fix the problem, I'd lose the themed tabs and other controls that I've come to love...

Fortunately this is only happening with one particular window, so as a quick and simple hack I simply added a Timer control (has to be System.Timers.Timer as System.Windows.Forms.Timer doesn't solve the problem) to the parent window, set Timer.Interval to 100 and Timer.Enabled to False. Then moved my code from the 'problem' eventhandler to the Timer.Elapsed event and added Timer.Stop on the first line. Then back in the original eventhandler I added Timer.Start. The result? Problem fixed.

Hopefully this will be resolved in Whidbey.

Comments

 

Bradley Uffner said:

.EnableVisualStyles, then immediatly after call Application.DoEvents. This should be done from a Sub Main BEFORE and forms or controls are instanciated.
September 13, 2004 6:41 PM
 

Kevin Gearing said:

Hi,

Application.DoEvents() doesn't actually solve the problem.

In the situation I had, I have a Startup module which performs various actions, including setting Application.EnableVisualStyles() way before instantiating any forms or controls.

The problem with Visual Styles in .NET Framework 1.1 is a confirmed bug and will be resolved in Whidbey. There is also talk of having a managed UxTheme wrapper.
September 16, 2004 2:20 PM
 

Venkat said:

Hi

I have the same problem when i invoke a form object, from another form, i am not able to fix the bug as it runs to the end of the main() , is there a way to fix the bug.

Regards
Venkat
June 20, 2005 4:17 PM
 

cadessi said:

Hi,

AFAIK, Skybound VisualStyles gives theme support to tabcontrols and tabPages; indeed i think it will give theme support to everycontrol. Anyway, i could remove Application.EnableVisualStyles() line without suffer any loss.
February 6, 2006 3:59 PM
 

dinkelburt said:

Well I'll be damned... works like a charm, thanks much!
September 28, 2006 12:15 AM
 

Rag said:

Hi,

We are getting same exception through from a form which posts its records to MSMQ Client Queue.

We do not have Application.EnableVisualStyles() method being called in our application.

Trace:-

A fatal error happened in
[namespace].ApplicationMain_ThreadException.

Exception type: System.Runtime.InteropServices.SEHException

Exception message:
External component has thrown an exception.

Exception stacktrace:
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr
wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
at System.Windows.Forms.Control.DefWndProc(Message& m)
at System.Windows.Forms.Control.WmUpdateUIState(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.ParkingWindow.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
April 17, 2007 6:27 AM
 

henok said:

i am trying to access parallel port but as i do i donwnloaded inpout32.dll to location in windows/system and even windows/system32 in my xp pc.But the error occurs when my program calls the software "System.Runtime.InteropServices.SEHException"

please help me>>>>>

May 17, 2008 11:12 PM

Leave a Comment

(required)  
(optional)
(required)  

Protected by FormShield
Refresh
Listen
Please enter the characters shown on the image


Code:


Add
Shopbot
Shopbot

 

 

Copyright ©2004-2007 Kevin Gearing. All Rights Reserved.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems