Vb.NET Addin Share Violation Error

Valued Contributor
Valued Contributor

Hi All

I have the following problem with ApplicationEvents in my VB.NET Addin.

 

I have

Private _CITOApp As SolidEdgeFramework.Application

Private _CITOAddin As SolidEdgeFramework.ISEAddInEx

Private _CITOApplicationEvents As SolidEdgeFramework.ISEApplicationEvents_Event

 

In OnConnection

_CITOApp = Application

_CITOAddin = AddInInstance

_CITOApplicationEvents = DirectCast(_CITOApp.ApplicationEvents, ISEApplicationEvents_Event)

 

AddHandler _CITOApplicationEvents.AfterActiveDocumentChange, AddressOf _CITOApplicationEvents_AfterActiveDocumentChange

 

Event works fine but when whole Document is closed and GC.Collect runs (by me or himself) error occurs

First-chance exception at 0x51bc2162 in Edge.exe: 0xC0000005: Access violation reading location 0x283cc3a4.

 

The number of errors is dependent upon the how many unique documents were opened.

 

Private Sub _CITOApplicationEvents_AfterActiveDocumentChange(theDocument As Object)

If Not theDocument Is Nothing Then

Dim a = Marshal.ReleaseComObject(theDocument)

Debug.Print("_CITOApplicationEvents_AfterActiveDocumentChange -> " & a)

End If

 

End Sub

 

 

It is irrelevant whether releasing or not releasing object

Marshal.ReleaseComObject(theDocument)

 

Errors can be seen when "Enable unmanaged code debugging" is checked.

 

Have I some chance to solve this problem?

regards,

Lubo

 

Posted by: Lubo
Post date: 9/9/2012 5:05:43 AM

1 REPLY

Re: Vb.NET Addin Share Violation Error

Valued Contributor
Valued Contributor

Do you see the exception if you don't connect up to the event?

 

I run GC when a document is closed (after we fire the event).

 

Have you tried generating an add-in using one of the vb add-in wizards I posted on line? If you have VS 2010, go to the new project dialog and click the "on line templates" button on the left side of the new project dialog. Then on the upper right side you will see a search box. Type "Solid" in the box. Two of the results that show up will be VB add-in wizards, one that has a UI, one that does not. Pick the one without a UI and all it does is connect up to the application events. What happens with that add-in?

 

Posted by: R.D. Holland
Post date: 9/18/2012 1:13:02 PM