.NET

Reply
Mentor
matus.brlit
Posts: 244
Registered: ‎03-11-2008
Message 1 of 6 (1,184 Views)
Accepted Solution

1073741819 (0xc0000005) 'Access violation'.

1184 Views, 5 Replies
06-28-2013 04:33 AM

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

Valued Contributor
sszabo
Posts: 86
Registered: ‎09-05-2012
Message 2 of 6 (1,173 Views)

Re: 1073741819 (0xc0000005) 'Access violation'.

06-28-2013 06:07 AM 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

Active Contributor
HomeBoyLV
Posts: 47
Registered: ‎06-04-2004
Message 3 of 6 (1,144 Views)

Re: 1073741819 (0xc0000005) 'Access violation'.

06-28-2013 05:52 PM 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

Active Contributor
HomeBoyLV
Posts: 47
Registered: ‎06-04-2004
Message 4 of 6 (1,143 Views)

Re: 1073741819 (0xc0000005) 'Access violation'.

06-28-2013 05:54 PM 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

Mentor
matus.brlit
Posts: 244
Registered: ‎03-11-2008
Message 5 of 6 (1,105 Views)

Re: 1073741819 (0xc0000005) 'Access violation'.

06-30-2013 11:34 PM in reply to: sszabo
thanks, cool tip
Mentor
matus.brlit
Posts: 244
Registered: ‎03-11-2008
Message 6 of 6 (1,103 Views)

Re: 1073741819 (0xc0000005) 'Access violation'.

06-30-2013 11:41 PM 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.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community