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. Visual Basic
  4. System.AccessViolationException Closing Windows Form Contianing An ActiveX Control

System.AccessViolationException Closing Windows Form Contianing An ActiveX Control

Scheduled Pinned Locked Moved Visual Basic
helpcomperformance
3 Posts 1 Posters 0 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
    Stinebaugh
    wrote on last edited by
    #1

    I'm kinda stumped on this one. I've been reading for a few hours now and still can't seem to figure out what the problem is. I'm working on a remote desktop tool that consists of a parent mdi form and child forms that contain an AxMSTSCLib control. Everything works great on my machine (Win 7), but when I attempt to run this on a Windows 2003 or XP box, the app crashes when it tries to close the form. At first I thought it was due to me trying to dispose the control, but even removing the dispose step makes no difference. I've included the error message along with some info from the immediate window and a dump analysisy showing the function call causing the access violation. I'm not sure what I have to do to keep this from throwing the error and crashing the app. An unhandled exception of type 'System.AccessViolationException' occurred in System.Windows.Forms.dll Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.


    Step into: Stepping over non-user code 'System.Windows.Forms.Form.Close' First-chance exception at 0x59366b49 in RDPConnectionManager.exe: 0xC0000005: Access violation reading location 0x00000000.


    mstscax!CMsTscAx::OnCoreApiDisconnected+87 mstscax!CTSWin32CoreApiNotifySink::OnCoreApiDisconnectedUiThreadWorker+19 mstscax!CTSWin32CoreApiNotifySink::OnCoreApiDisconnectedUiThreadWorkerAsyncCallback::Invoke+16 mstscax!CTSMsg::Invoke+44 mstscax!CTSThread::RunQueueEvent+73 mstscax!CTSThread::RunAllQueueEvents+57 mstscax!CTSThread::OnNotifyThreadEventQueue+7 mstscax!CTSThread::OnNotifyThreadMessage+24 mstscax!PAL_System_Win32_ThreadWndProc+1b user32!InternalCallWinProc+28 user32!UserCallWinProcCheckWow+150 user32!DispatchMessageWorker+306 user32!DispatchMessageW+f


    Let me know if you need any additional information on this problem and I appreciate any input on this.

    S 1 Reply Last reply
    0
    • S Stinebaugh

      I'm kinda stumped on this one. I've been reading for a few hours now and still can't seem to figure out what the problem is. I'm working on a remote desktop tool that consists of a parent mdi form and child forms that contain an AxMSTSCLib control. Everything works great on my machine (Win 7), but when I attempt to run this on a Windows 2003 or XP box, the app crashes when it tries to close the form. At first I thought it was due to me trying to dispose the control, but even removing the dispose step makes no difference. I've included the error message along with some info from the immediate window and a dump analysisy showing the function call causing the access violation. I'm not sure what I have to do to keep this from throwing the error and crashing the app. An unhandled exception of type 'System.AccessViolationException' occurred in System.Windows.Forms.dll Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.


      Step into: Stepping over non-user code 'System.Windows.Forms.Form.Close' First-chance exception at 0x59366b49 in RDPConnectionManager.exe: 0xC0000005: Access violation reading location 0x00000000.


      mstscax!CMsTscAx::OnCoreApiDisconnected+87 mstscax!CTSWin32CoreApiNotifySink::OnCoreApiDisconnectedUiThreadWorker+19 mstscax!CTSWin32CoreApiNotifySink::OnCoreApiDisconnectedUiThreadWorkerAsyncCallback::Invoke+16 mstscax!CTSMsg::Invoke+44 mstscax!CTSThread::RunQueueEvent+73 mstscax!CTSThread::RunAllQueueEvents+57 mstscax!CTSThread::OnNotifyThreadEventQueue+7 mstscax!CTSThread::OnNotifyThreadMessage+24 mstscax!PAL_System_Win32_ThreadWndProc+1b user32!InternalCallWinProc+28 user32!UserCallWinProcCheckWow+150 user32!DispatchMessageWorker+306 user32!DispatchMessageW+f


      Let me know if you need any additional information on this problem and I appreciate any input on this.

      S Offline
      S Offline
      Stinebaugh
      wrote on last edited by
      #2

      OK, I figured out the reason for the exception. I was closing/disposing of the form within an eventhandler for a control on that form. So basically, I killed the form and then the event tried to finish running and threw the exception. This leads me to another question though. How do I close this form outside of this event? The event in question is OnDisconnected event of the AxMsRdpClient4 class. I want to close the form after disconnecting, but it seems like any attempt I make to close the form within that event will result in the exception.

      S 1 Reply Last reply
      0
      • S Stinebaugh

        OK, I figured out the reason for the exception. I was closing/disposing of the form within an eventhandler for a control on that form. So basically, I killed the form and then the event tried to finish running and threw the exception. This leads me to another question though. How do I close this form outside of this event? The event in question is OnDisconnected event of the AxMsRdpClient4 class. I want to close the form after disconnecting, but it seems like any attempt I make to close the form within that event will result in the exception.

        S Offline
        S Offline
        Stinebaugh
        wrote on last edited by
        #3

        FYI to anyone who may come across this issue. I was able to find a workaround to this issue by using a timer that closed the form after the disconnect event had finished. Here is a link to the solution: http://www.codeproject.com/Messages/3622059/Run-Code-Fire-Event-After-First-Event-Finishes.aspx[^]

        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