Invalid FORMATETC structure

I recently ran into this problem with Visual Studio while trying to drag & drop a component onto a web page.

image

---------------------------
Microsoft Visual Studio
---------------------------
The operation could not be completed. Invalid FORMATETC structure

image

---------------------------
Microsoft Visual Studio
---------------------------
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

 

I posted about the same exact problem previously.  Unfortunately, the solution to the problem that I posted a while ago involved reloading the project references.

But this time, for me, the project has grown to over 19 sub projects, and I wasn't going to spend the next hour trying to reload all the project dependencies.  So, I attempted to find what was the root cause of the problem.

Aarthi at MSFT, said the underlying bottom line was a reference problem, but, again, nothing new.  So after playing with Visual Studio, I found how to re-produce the problem (at least for my case).  There are several situations when this error occurs:

1) Unloaded projects cause Invalid FORMATETC

I had recently unloaded a project that used Script#:

image

This was causing Visual Studio Toolbar to choke on the FORMATETC error.

2) Old System.Web.Extensions and ASP.NET 3.5

I've also found that if you've recently upgraded a web project that previously used the "downloaded" AJAX Extensions for ASP.NET 2.0 in VS2005.  If you still have the the "downloaded" System.Web.Extensions.dll lingering around in WebApp\Bin folder, the GAC, or referenced in your VS Toolbox then you'll come across this error.  To resolve the issue, make sure you remove all references to the "downloaded" System.Web.Extensions.dll for ASP.NET 2.0 when using Visual Studio 2008.  ASP.NET 3.5 comes with System.Web.Extensions included which is why this error occurs in Visual Studio due to the two conflicting versions of System.Web.Extensions.

Hope that helps!

Brian