Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Not getting the reason for 'Application.OnThreadException' raised.

Not getting the reason for 'Application.OnThreadException' raised.

Scheduled Pinned Locked Moved C#
c++data-structuresdebuggingtoolshelp
5 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    srng net
    wrote on last edited by
    #1

    Hi all, I am developing a winform application.This application has several (approx. 45) windows with custom rendering on it. I am also using a third party tool for docking and undocking these windows. When I play with all these windows (like docking undocking and moving them from thier location etc) very rarely I face this issue of an 'Application.OnThreadException'. The custom rendering of all windows is heavy process. Following A) is Exception and B) is the Stack trace I got once the exception has occured. This issue is very hard to reproduce but it is there for sure. Could you please guide me regarding any possible reason for the same? Thanks in advance! A) ---Exception Message --- Object reference not set to an instance of an object. B) ----Stack Trace--- System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.OnThreadException(System.Exception t) + 0x8b bytes System.Windows.Forms.dll!System.Windows.Forms.Control.WndProcException(System.Exception e) + 0x16 bytes System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnThreadException(System.Exception e) + 0xc bytes System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.Callback(System.IntPtr hWnd, int msg = 562, System.IntPtr wparam, System.IntPtr lparam) + 0x72 bytes System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DefWndProc(ref System.Windows.Forms.Message m = {msg=0x232 (WM_EXITSIZEMOVE) hwnd=0xa0cbc wparam=0x0 lparam=0x0 result=0x0}) + 0x130 bytes System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.WndProc(ref System.Windows.Forms.Message m) + 0x5 bytes Syncfusion.Tools.Windows.dll!Syncfusion.Windows.Forms.Tools.NotifyNativeWindow.WndProc(ref System.Windows.Forms.Message m = {msg=0x232 (WM_EXITSIZEMOVE) hwnd=0xa0cbc wparam=0x0 lparam=0x0 result=0x0}) + 0xb3 bytes System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr hWnd, int msg = 562, System.IntPtr wparam, System.IntPtr lparam) + 0x57 bytes [Native to Managed Transition] System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DefWndProc(ref System.Windows.Forms.Message m = {msg=0x112 (WM_SYSCOMMAND) hwnd=0xa0cbc wparam=0xf012 lparam=0x10f0494 result=0x0}) + 0x93 bytes System.Windows.Forms.dll!System.Windows.Forms.Form.DefWndProc(ref System.Windows.Forms.Message m) + 0x89 bytes System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m) + 0x40a bytes System.Windows.Forms.dll!System.Windows.Forms.

    L 1 Reply Last reply
    0
    • S srng net

      Hi all, I am developing a winform application.This application has several (approx. 45) windows with custom rendering on it. I am also using a third party tool for docking and undocking these windows. When I play with all these windows (like docking undocking and moving them from thier location etc) very rarely I face this issue of an 'Application.OnThreadException'. The custom rendering of all windows is heavy process. Following A) is Exception and B) is the Stack trace I got once the exception has occured. This issue is very hard to reproduce but it is there for sure. Could you please guide me regarding any possible reason for the same? Thanks in advance! A) ---Exception Message --- Object reference not set to an instance of an object. B) ----Stack Trace--- System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.OnThreadException(System.Exception t) + 0x8b bytes System.Windows.Forms.dll!System.Windows.Forms.Control.WndProcException(System.Exception e) + 0x16 bytes System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnThreadException(System.Exception e) + 0xc bytes System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.Callback(System.IntPtr hWnd, int msg = 562, System.IntPtr wparam, System.IntPtr lparam) + 0x72 bytes System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DefWndProc(ref System.Windows.Forms.Message m = {msg=0x232 (WM_EXITSIZEMOVE) hwnd=0xa0cbc wparam=0x0 lparam=0x0 result=0x0}) + 0x130 bytes System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.WndProc(ref System.Windows.Forms.Message m) + 0x5 bytes Syncfusion.Tools.Windows.dll!Syncfusion.Windows.Forms.Tools.NotifyNativeWindow.WndProc(ref System.Windows.Forms.Message m = {msg=0x232 (WM_EXITSIZEMOVE) hwnd=0xa0cbc wparam=0x0 lparam=0x0 result=0x0}) + 0xb3 bytes System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr hWnd, int msg = 562, System.IntPtr wparam, System.IntPtr lparam) + 0x57 bytes [Native to Managed Transition] System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DefWndProc(ref System.Windows.Forms.Message m = {msg=0x112 (WM_SYSCOMMAND) hwnd=0xa0cbc wparam=0xf012 lparam=0x10f0494 result=0x0}) + 0x93 bytes System.Windows.Forms.dll!System.Windows.Forms.Form.DefWndProc(ref System.Windows.Forms.Message m) + 0x89 bytes System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m) + 0x40a bytes System.Windows.Forms.dll!System.Windows.Forms.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      srng.net wrote:

      Could you please guide me regarding any possible reason for the same?

      The reason is quite simple, as noted in the exception message you have an uninitialised object reference. The cause, however, is far more difficult to determine. You need to look at the code to try and see what references are being made/used around the point of the exception. Perhaps add some debug code or link to your program with the debugger when the exception occurs. Since you are using a third psrty tool you may also like to talk to the suppliers to see if it could be an issue with their code.

      It's time for a new signature.

      S 1 Reply Last reply
      0
      • L Lost User

        srng.net wrote:

        Could you please guide me regarding any possible reason for the same?

        The reason is quite simple, as noted in the exception message you have an uninitialised object reference. The cause, however, is far more difficult to determine. You need to look at the code to try and see what references are being made/used around the point of the exception. Perhaps add some debug code or link to your program with the debugger when the exception occurs. Since you are using a third psrty tool you may also like to talk to the suppliers to see if it could be an issue with their code.

        It's time for a new signature.

        S Offline
        S Offline
        srng net
        wrote on last edited by
        #3

        Hi Richard, Thanks for the reply. The reason is not the one which is seen at upper level.(Object not set to an instance of an object) This is caused due to Application.ThreadContext.OnThreadException. Here I am not able to get the reason for Application.ThreadContext.OnThreadException. If you see the detailed log, there we can ,after NativeWindow.Callback this exception is raised inside System.Windows.Forms.dll. Why the dll has raised an exception? My point of view, This can not be becasue of third party tool. Reason : Again we can look into the StackTrace where the exception is raised by System.Windows.forms.dll and third party tool is just passing comand to WM_ExitSizeMove and leaving the handle to windows. I need to know Why this exception is raised.

        L D 2 Replies Last reply
        0
        • S srng net

          Hi Richard, Thanks for the reply. The reason is not the one which is seen at upper level.(Object not set to an instance of an object) This is caused due to Application.ThreadContext.OnThreadException. Here I am not able to get the reason for Application.ThreadContext.OnThreadException. If you see the detailed log, there we can ,after NativeWindow.Callback this exception is raised inside System.Windows.Forms.dll. Why the dll has raised an exception? My point of view, This can not be becasue of third party tool. Reason : Again we can look into the StackTrace where the exception is raised by System.Windows.forms.dll and third party tool is just passing comand to WM_ExitSizeMove and leaving the handle to windows. I need to know Why this exception is raised.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Since this appears to be somewhat random I can only repeat my previous suggestion that you add debug code or trap the application with he debugger when the exception occurs. Without understanding your code or the third party library it is impossible to make any other suggestions.

          It's time for a new signature.

          1 Reply Last reply
          0
          • S srng net

            Hi Richard, Thanks for the reply. The reason is not the one which is seen at upper level.(Object not set to an instance of an object) This is caused due to Application.ThreadContext.OnThreadException. Here I am not able to get the reason for Application.ThreadContext.OnThreadException. If you see the detailed log, there we can ,after NativeWindow.Callback this exception is raised inside System.Windows.Forms.dll. Why the dll has raised an exception? My point of view, This can not be becasue of third party tool. Reason : Again we can look into the StackTrace where the exception is raised by System.Windows.forms.dll and third party tool is just passing comand to WM_ExitSizeMove and leaving the handle to windows. I need to know Why this exception is raised.

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #5

            srng.net wrote:

            My point of view, This can not be becasue of third party tool. Reason : Again we can look into the StackTrace where the exception is raised by System.Windows.forms.dll and third party tool is just passing comand to WM_ExitSizeMove and leaving the handle to windows.

            The problem can very well be inside the third party library, or how you're using it. If your updating controls from anything other than the UI thread, behavior is unpredictable. It should throw an exception about the cross-thread boundry call, but that's not guaranteed to be thrown in all cases. I'd get with SyncFusion about this and explain what the circumstances are that threw the exception, how the control is being used, ...

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups