.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

1073741819 (0xc0000005) 'Access violation'.

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
matus.brlit
4969 Views, 5 Replies

1073741819 (0xc0000005) 'Access violation'.

The program '[6352] acad.exe: Managed (v4.0.30319)' has exited with code -1073741819 (0xc0000005) 'Access violation'.

 

This is the last line from the output window. Before that, i have couple of warning about dispose call and first chance exceptions:

 

A first chance exception of type 'Autodesk.AutoCAD.Runtime.Exception' occurred in AcdbMgd.dll
A first chance exception of type 'Autodesk.AutoCAD.Runtime.Exception' occurred in AcdbMgd.dll
Forgot to call Dispose? (Autodesk.AutoCAD.DatabaseServices.BlockTableRecord): DisposableWrapper
Forgot to call Dispose? (Autodesk.AutoCAD.DatabaseServices.BlockTableRecord): DisposableWrapper

 

I have chacked all exceptions in the debug settings, but still no exception is thrown and autocad just falls down.

 

Any idea, how to catch this exception?

 

Thanks

5 REPLIES 5
Message 2 of 6
sszabo
in reply to: matus.brlit

Your plugin runs in the same .NET AppDomain as Autocad so theoretically you should be able to catch all uncaught exceptions in an IExtensionApplication as such:

 

Public Sub Initialize() Implements _
        Autodesk.AutoCAD.Runtime.IExtensionApplication.Initialize
            AddHandler AppDomain.CurrentDomain.FirstChanceException, AddressOf GlobalExHappened
            AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf UnhandledExHappened
 End Sub

 

    Public Sub GlobalExHappened(source As Object, e As FirstChanceExceptionEventArgs)
        log.FatalException(e.Exception)
    End Sub

    Public Sub UnhandledExHappened(source As Object, e As UnhandledExceptionEventArgs)
        log.FatalException(e)
    End Sub

Message 3 of 6
HomeBoyLV
in reply to: matus.brlit

Just a guess, but this 'Looks' like the clasic .NET Dispose issue. You must Dispose of AutoCAD referanced objects explicetly. AutoCAD runs on a single thred; The .NET Garbage collector can call .Dispose from another thread, which is bad. Make sure you use 'Using' (For VB) the vars, or that you call dispose of them with a direct call of Dispose. This is usually a 'random'ish crash, can you reproduce it?

 

HomeBoy Out

Message 4 of 6
HomeBoyLV
in reply to: sszabo


@sszabo wrote:

Your plugin runs in the same .NET AppDomain as Autocad so theoretically you should be able to catch all uncaught exceptions in an IExtensionApplication as such:

 

Public Sub Initialize() Implements _
        Autodesk.AutoCAD.Runtime.IExtensionApplication.Initialize
            AddHandler AppDomain.CurrentDomain.FirstChanceException, AddressOf GlobalExHappened
            AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf UnhandledExHappened
 End Sub

 

    Public Sub GlobalExHappened(source As Object, e As FirstChanceExceptionEventArgs)
        log.FatalException(e.Exception)
    End Sub

    Public Sub UnhandledExHappened(source As Object, e As UnhandledExceptionEventArgs)
        log.FatalException(e)
    End Sub


Cool, I did'nt know that! Thanks

 

HomeBoy Out

Message 5 of 6
matus.brlit
in reply to: sszabo

thanks, cool tip
Message 6 of 6
matus.brlit
in reply to: HomeBoyLV

thanks HomeBoy, you were right,

I found the cause after i read Kean's blog here: http://through-the-interface.typepad.com/through_the_interface/2008/06/cleaning-up-aft.html

 

I created a BlockTableRecord object, that I meant to use later, but not in all branches, so sometimes, it was not added to transaction and then AutoCAD crashed, when I closed the window. That's why it was hard to reproduce, because it didn't crash after the action, but when the garbage collector came in action, which was not after each close.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost