AccessViolationException

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

AccessViolationException
 
briannesbitt




Posts: 81
Joined: 2010-05-24
Hi there,

We have a new installation of our add-in and for the first time a few of the users are getting a PowerPoint crash.
We got some logging information from the systems today (remotely).


System.Runtime.InteropServices.COMException (0x8001010A): The message filter indicated that the application is busy. (Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER))
at Microsoft.Office.Interop.PowerPoint.Shape.get_Tags()


Sometimes we simply see this exception:

System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at Microsoft.Office.Interop.PowerPoint.View.Paste()
... our code stack


Other times we get a message filter exception followed by a AccessViolationException. Both end up in a PowerPoint crash.

This part of the add-in writes some data to the clipboard and tries to execute a PowerPoint paste simulating a copy and paste procedure.


// 'bytes' holds some binary data that was originally copied from the clipboard.  

var bb = new byte[bytes.Length];
Buffer.BlockCopy(bytes, 0, bb, 0, bytes.Length);
Clipboard.SetData("Art::GVML ClipFormat", new MemoryStream(bb));

DocumentWindow dw;
View view;

try
{
	dw = _powerpoint.ActiveWindow;   // _powerpoint == "_Application"
	view = dw.View;
	view.Paste();
}
finally
{
	if (view != null)
         {
            Marshal.ReleaseComObject(view);
            view = null;
         }

	 if (dw != null)
         {
            Marshal.ReleaseComObject(dw);
            dw = null;
         }
}


It seems like we are getting the AccessVioloation on the view.Paste() call. Any ideas there? This is really the first we have seen this and our add-in is running on many other computers.

From a clean reboot it seems the exception will occur on the 2nd attempt to run this code. Once PowerPoint crashes it will then happen every time after restarting. Though there is a PowerPnt.exe hanging around after the crash. Once we kill the left over instance we rerun PowerPoint then the crash occurs on the 2nd attempt again.

This is with Office 2010 x32 on Windows 7 if that helps.

Thanks!
Posted 03 Mar, 2016 23:04:35 Top
Andrei Smolin


Add-in Express team


Posts: 14115
Joined: 2006-05-11
Hello Brian,

Do you execute that code in a background thread? If so, move it to the main thread.

Regards from Belarus (GMT+3),‎

Andrei Smolin
Add-in Express Team Leader
Posted 04 Mar, 2016 00:45:16 Top
briannesbitt




Posts: 81
Joined: 2010-05-24
No. Its all in the main thread triggered by mouse actions. When I step through it locally the AddInStartup runs in thread id 1 and so does this code.
Posted 04 Mar, 2016 08:32:05 Top
Andrei Smolin


Add-in Express team


Posts: 14115
Joined: 2006-05-11
Hello Brian,

I suppose this occurs when there's a modal form/dialog open or when user performs some actions (can't say what actions) that the object model is busy. Say, check if this occurs when the BackstageView is open.

I would also try to paste the ClipBoard content manually. Kill the hanging POWERPNT.EXE previously.

Regards from Belarus (GMT+3),‎

Andrei Smolin
Add-in Express Team Leader
Posted 04 Mar, 2016 09:11:17 Top
briannesbitt




Posts: 81
Joined: 2010-05-24
It seems our issue is exactly like this one.

https://www.add-in-express.com/forum/read.php?FID=5&TID=8340

Did using the "wait a little" trick work? Seems the thread died with no "real" solution.

We have an interface in our solution that you can pass in a lambda to run on an OnSendMessage execution from anywhere.
Posted 04 Mar, 2016 10:05:31 Top
Andrei Smolin


Add-in Express team


Posts: 14115
Joined: 2006-05-11
Brian,

In that thread they wrote:


We finally found the source of the AccessViolationExceptions during the .Paste() call. The software, which we use for remote support, tries to synchronize the clipboards between the two PCs and seems to lock it while transferring data. When we call the .Paste() method, PowerPoint tries to access the locked clipboard and thus throws the exception. Using a different remote session software resolved the issue.


Note that I was able to reproduce that issue on my PC without that remote support software product. I suppose I have (had?) something on my machine that prevented pasting. Do you want me to test this on my machine? Did you try to reproduce this issue on another machine?

Regards from Belarus (GMT+3),‎

Andrei Smolin
Add-in Express Team Leader
Posted 04 Mar, 2016 10:20:27 Top
briannesbitt




Posts: 81
Joined: 2010-05-24
What do you have on your machine to prevent pasting? Anti-virus? Clipboard manager?

I am going to try and re-create the issue locally and/or with a smaller add-in project.

BTW is there any significant difference between View.Paste() (https://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.view.paste(v=office.14).aspx) and Shapes.Paste() (https://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.shapes.paste(v=office.14).aspx) ?
Posted 04 Mar, 2016 11:05:17 Top
Andrei Smolin


Add-in Express team


Posts: 14115
Joined: 2006-05-11
Hello Brian,

briannesbitt writes:
What do you have on your machine to prevent pasting? Anti-virus? Clipboard manager?


I don't know.

briannesbitt writes:
BTW is there any significant difference between View.Paste() and Shapes.Paste()


I only see a formal difference.

Regards from Belarus (GMT+3),‎

Andrei Smolin
Add-in Express Team Leader
Posted 07 Mar, 2016 03:17:09 Top
briannesbitt




Posts: 81
Joined: 2010-05-24
We have round out some more information. We were able to recreate the issue here in one situation. We installed Office 2010 on windows 7 inside a virtualbox (https://www.virtualbox.org/) instance. The host was a windows 8 machine.

Everything worked fine initially. When you install the virtualbox guest additions which enables clipboard sharing between guest and host an app called VBoxTray runs and installs a clipboard watcher. As soon as you do this we saw the AccessViolation crashes, probably similar to the other thread. You also see the exceptions occur now in the Host machine as well. If you stop VBoxTray.exe from running the error goes away. Its actually open source here:
https://www.virtualbox.org/browser/vbox/trunk/src/VBox/Additions/WINNT/VBoxTray

We tried a few things and were able to circumvent the error with the "wait a little". I think its a timing issue from when we write to the clipboard, the external vboxtray clipboard listener reads and updates the host clipboard and then us instructing PowerPoint to paste. Waiting a little in-between those actions seems to let the external clipboard listener run.

We are still not sure exactly what on our client end is causing the AccessViolation, but given this information we are fairly convinced its a conflict with PowerPoint and some application with a clipboard listener doing something similar with the clipboard (probably not virtualbox).

We tried installing 2013 and didn't see the crash with VBoxTray running or not. Given this is would seem to be a PowerPoint issue and how it handles the Clipboard when pasting.
Posted 08 Mar, 2016 11:27:21 Top
Andrei Smolin


Add-in Express team


Posts: 14115
Joined: 2006-05-11
Hello Brian,

That's great! Please let me know if this works on the customer's machine as well.

Regards from Belarus (GMT+3),‎

Andrei Smolin
Add-in Express Team Leader
Posted 09 Mar, 2016 01:17:28 Top