SharePoint and COMException (0x80004005): Cannot complete this action

Posted by Damon on Simple Talk See other posts from Simple Talk or by Damon
Published on Wed, 26 May 2010 19:40:13 GMT Indexed on 2010/05/26 19:43 UTC
Read the original article Hit count: 783

Filed under:

I ran into a small issue today working on a deployment.  We were moving a custom ASP.NET control from my development environment into a SharePoint layout page on a staging environment .  I was expecting some minor issues to arise since I had developed the control in an ASP.NET website project, but after getting everything moved over we got an obscure COMException error the that looked like this:


Cannot complete this action.

Please try again.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Cannot complete this action.

[COMException (0x80004005): Cannot complete this action.

.Lengthy stack trace goes here.


Everything in the custom control was built using managed code, so we weren't sure why a COMException would suddenly appear. The control made use of an ITemplate to define its UI, so there was a lot of markup and binding code inside the template. As such, we started taking chunks of the template out of the layout page and eventually the error went away.  It was being caused by a section of code where we were calling a custom utility method inside some binding code:

<%# WebUtility.FormatDecimal(.) %>

Solution:

It turns out that we were missing an Assembly and Import directive at the top of the page to let the page know where to find this method.  After adding these to the page, the error went away and everything worked great.  So a COMException (0x80004005) Cannot complete this action error is just SharePoint's friendly way of letting you know you're missing an assembly or imports reference.

© Simple Talk or respective owner