System.AccessViolationException

Add-in Express™ Support Service
That's what is more important than anything else

System.AccessViolationException
Attempted to read or write protected memory. This is often an indication that other memory is corrupt. 
Subscribe
Nachtinho Nachtigall




Posts: 8
Joined: 2024-05-03
Hi,
some of our customers are experiencing this error when starting Word with our add-in. We believe it is happening after an Office update, but we have not been able to verify that yet.

Microsoft Office : MS Office 365 x 64
Operating system: Windows 11

Application Domain: C:\Program Files (x86)\SAP\SAP Disclosure Management\
Assembly Codebase: file:///C:/WINDOWS/assembly/GAC_MSIL/office/15.0.0.0__71e9bce111e9429c/office.dll
Assembly Full Name: office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c
Assembly Version: 15.0.0.0

Exception Source: office
Exception Type: System.AccessViolationException
Exception Message: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Exception Target Site: set_Caption

---- Stack Trace ----
Microsoft.Office.Core._CommandBarButton.set_Caption(pbstrCaption As String)
office.dll: N 00000 (0x0) JIT
CundusWordAddIn.AddinModuleWord.SetButtonStyle(CmdBarButton As CommandBarButton&, sCaption As String, ButtonTag As GuiEventTypes, id As Int32, IsFaceId As Boolean, bBeginGroup As Boolean, ToolTip As String, addhandling As Boolean)
AddinModuleWord.vb: line 2356, col 17, IL 0146 (0x92)
CundusWordAddIn.AddinModuleWord.AddOleObjectContextMenue()
AddinModuleWord.vb: line 1975, col 09, IL 0451 (0x1C3)
CundusWordAddIn.AddinModuleWord.AddMenus()
AddinModuleWord.vb: line 2248, col 09, IL 0065 (0x41)
AddinExpress.MSO.ADXHostActiveObject_EventHandler.Invoke(sender As Object, hostObj As Object)
office.dll: N 00000 (0x0) JIT
AddinExpress.MSO.ADXWordAppEvents.DoNewDocument(doc As Object)
office.dll: N 0018 (0x12) IL


Have you encountered this error before? It has also occurred with 'Face Id' instead of 'Caption'.

Kind regards,
Guido
Posted 18 Sep, 2024 06:30:21 Top
Andrei Smolin


Add-in Express team


Posts: 19011
Joined: 2006-05-11
Hello Guido,

The call stack suggests that you set up an ADXCommandBarButton on an ADXContextMenu; you do this in the DocumentOpen event.

I would check how the same code work when invoked from a test CommandBar/Ribbon button. If the exception doesn't occur, you can introduce a small delay between the DocumentOpen event and setting up the button; check section Wait a little; see the PDF file in the folder {Add-in Express}\Docs on your development PC. If, however, you get the same exception, you would need to switch to using Ribbon controls; for starters, check section Step #7 – Designing custom Ribbon UI.

Regards from Poland (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 18 Sep, 2024 08:00:08 Top
Nachtinho Nachtigall




Posts: 8
Joined: 2024-05-03
Hi Andrei,

thanks for the response.
Do you mean I should implement 'Wait a little' on the DocumentOpen event
and start adding the context menue when I get the message back ?

Kind regards,
Guido
Posted 18 Sep, 2024 10:06:22 Top
Andrei Smolin


Add-in Express team


Posts: 19011
Joined: 2006-05-11
Hello Guido,

Yes, exactly. But first, make sure that adding the context menu works if invoked from a test button.

Regards from Poland (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 18 Sep, 2024 11:05:56 Top
Nachtinho Nachtigall




Posts: 8
Joined: 2024-05-03
sorry - reload failure
Posted 18 Sep, 2024 11:52:38 Top