Solution: Invalid FORMATETC structure
I was making a ASP.NET components library and when I was ready with my library I made a Web Application project and started dragging and dropping to them my form.
To my surprise, I was not able to do so and I got following error.
The operation could not be completed. Invalid FORMATETC structure
Many of you may also get a similar error:
Invalid FORMATETC structure (Exception from HRESULT: 0×80040064 (DV_E_FORMATETC))
After few hours extensive searching on net and trying out many solutions, I got to know few things.
Microsoft uses this exception in many scenarios and not in a specific situation. This means the root causes can be different but it will show you only this error.
This makes you to try many solution. Unfortunately no solution listed on Internet worked for me and I was forced to find my own.
I’m listing my solution along with other solutions that may work.
————————————————————————————–
See Also: MCTS 70-630 all you need to know to clear this exam
————————————————————————————–
I highly recommend to read all solutions and try the simpler ones first and then go for complex ones. This will save your day.
Solution 1:
ASP.NET 3.5
In my case I was using following hierarchy.
ASP.NET Button -> ThemedButton -> DesktopButton.
I didn’t wanted developers to start using ThemedButton so I don’t wanted to show it on toolbox.
So I put some attributes to it. Like below:
[DefaultProperty("Text"), ToolboxData("<{0}:ThemedButton runat=server>"), ToolboxItem(false), DesignTimeVisible(false)]
I don’t know the root cause, but removing following piece of code worked for me.
ToolboxItem(false)
Solution 2:
Resetting toolbox items has also helped many of them. (very simple solution)
Solution 3:
Remove all project reference and add them one by one. Recompile and done!
Solution 4:
Check if you are using old Ajax controls library. Make sure you use the latest one.
(Brian Chavez has posted a solution on this: Check here)
Solution 5:
Unloading a project that used Script#
(Brian Chavez has posted a solution on this: Check here)
Solution 6:
Unloading and re-loading the project. (very stupid, but works somehow)
Solution 7:
Adding new web.config file.
Just remove the old one and add a new one and then transfer your customizations (if any) to the new one from old one.
If you know more, then please comment.
Hi you saved my time. Good Solution.Thanks
February 6th, 2009 at 12:26 PM1. Exit VS 2. Delete *.suo file 3. Restart VS
March 25th, 2009 at 9:34 PMto Dmitry Gusev:Right said. This works too.
March 26th, 2009 at 8:26 AM[...] at one point or another. This error has popped up in numerous blogs and forum posts and there’s a list of solutions (and possible causes) which seems to work for most folks. Well, the bug still rears its ugly head [...]
May 17th, 2009 at 1:03 PMSolution 3.
Check the version of the AjaxControlToolkit.dll in the /bin. In my case, I removed all the reference to ajaxtoolkit and delete the .dll. Add the new version of the toolkit.
Aloha.
May 19th, 2009 at 10:45 PMA solution:
1. Put the control in an other project (class
libary). We call this project X.
2. Build project X.
2. Set a reference to the project X.
3. Open the page you want to use the control on it.
4. You will see in the toolbox the control. Take this and drag to your form.
this worked on a Windows XP, Visual Studio 2008 with a project that uses asp.net 3.5.
October 13th, 2009 at 7:48 PMYes. Thenproblem was that the files (folder of components) were moved..
October 16th, 2009 at 9:19 AMbst rgds.
Yuri
In WebControls that are derived from others, no control in the inheritance chain is permitted 1) to have ToolBoxItem(False), or 2) be without a valid ToolBoxData attribute, otherwise the error occurs. This applies even to MustInherit/abstract controls. That last point is important. Note that abstract controls, due to their abstract nature, are automatically excluded from toolbox.
October 29th, 2009 at 5:36 AMReset tool box = WIN! Thanks, bud!
November 4th, 2009 at 1:32 AMThank u very much
it worked
Rahul
November 13th, 2009 at 1:12 PMThis line is wrong
[ToolboxData( "" )]
This line is correct
[ToolboxData( "" )]
‘server’ element in “runat=server” directive must be surrouned with quotation marks
November 24th, 2009 at 9:54 PMthank you! reset of toolbox solved this issue.
December 6th, 2009 at 8:27 PMThank you very much. Resetting the toolbox worked.
December 8th, 2009 at 4:54 PMIn Team system 2008 looks like the VS can not somehow overwrite the web.config file .. so you need to manually add a couple of lines to your web.config … what are they ????
simply do the following:
1- create new local website.
2-add report viewer component to the default page
3- see the changes on the web.config file and add them to your original non-working website.
PEACE ..
December 8th, 2009 at 8:19 PM1. Right click on your project, Select “Clean”
2. Right click on your project, Select “Build”
Cheers.
December 23rd, 2009 at 12:07 AMHi there,
For me it was the read-only attribute of my web.config file which was checked!
It appears too when trying to add a user control from a non-standard library with a bad structured web.config (close tag not present for instance).
The designer add automatically assembly dependancies in web.config and add the close tag on the same line after the last dependance. When deleting all dependances, I delete the close tag too… Oups! When I tried to add the user control (non-standard one) on my page, the error has thrown.
Best wishes…
Ciao
January 6th, 2010 at 9:59 PM[...] point or another. This error has popped up in numerous blogs and forum posts and there’s a list of solutions (and possible causes) which seems to work for most folks. Well, the bug still rears its ugly head [...]
January 7th, 2010 at 8:56 AMIn my case, the error comes from web.config, for a extrange reason, when i drag and drop control, the vs2008 not add that lines to web.config.
March 28th, 2010 at 3:58 PMSolve, doing drag and drop in new proyect, and copy lines from new project(in web.config) to old and problematic web.config:
“add this in that “
Sorry, i forgot to tell, remember to add reference to the project.
March 28th, 2010 at 4:01 PMSolution 2 worked for me. Thanks.
April 7th, 2010 at 8:55 PMReset toolbox helps…
May 16th, 2010 at 8:31 AMDelete *.suo worked for me! Tks!
July 20th, 2010 at 4:49 PMI renamed my web.config then created a new one. When I dragged the component it worked. Then I deleted the new web config and renamed my old to the original name. All things worked.
July 22nd, 2010 at 3:37 AMI tried most other solutions but eventually it was Solution #1 that worked: Don’t bother changing ToolboxItem to true or false, just remove that attribute. Thanks for this page!
August 23rd, 2010 at 7:19 AMSolution 9 worked for me, Visual Studio 2008 Pro, ASP.Net 3.5 – XP. Thanks
October 27th, 2010 at 5:36 PMThank you very much
December 14th, 2010 at 3:49 PMI was having the same issue but now it is resolved. I simply reset my toolbox and then again added the controls to new tab and then it was working fine
sometime Class Access Modifiers has to Private
February 11th, 2011 at 9:52 AMtry change to Public
My project was checked into source control (TFS), which caused all my non-checked out files to be locked. When I tried to add an Infragistics control I got the invalid FORMATETC message.
After seeing your tip with web.config I realized that Infragistics probably needed to write to the web.config file but was unable to, since the file is write-protected while in source control. I checked out the file (which made it writable) and suddenly it worked. You may want to add a tip to Solution 7 that the file must be writable.
Thanks!
July 5th, 2011 at 1:33 PM