Finding HRESULT: 0x80020009 (DISP_E_EXCEPTION) 

Tags: MOSS/WSS, .NET

Sometimes you get this error, and (as usually) the log does not provide a lot of information, the error seems to be caused in MOSS own source code and apparently has nothing to do with yours. The error really says that an already disposed object is trying to be used.

When will you usually get this exception? When you assign an already created object to a variable, dispose the variable and try to use the first object again, the most typical case is something like this:

using (SPSite site = SPContext.Current.Site)

{

}

The using disposes automatically the “site” variable and when the system (or yourself) tries to use the SPContext.Current.Site object the exception arises from the system code, so it can be difficult to debug and find the source of the problem.

 
Published by Enrique Blanco  16-Sep-09
2 Comments  |  Trackback Url
 

Comentarios


carlos comentado en Tuesday, 22-Sep-2009
Although the rules to dispose object in SharePoint are tricky, I would recommend reading http://msdn.microsoft.com/es-es/library/aa973248(en-us).aspx article, and use DisposeCheck Tool. Being said that, it is not recommended to dispose SPContext objects as the are managed by the SharePoint framework. As stated before by Enrique.


Enrique comentado en Tuesday, 22-Sep-2009
I didn't know I had such a high level Audience ;)!!! Happy to see you around here Carlos!

You can comment here:
Use <br/> for linebreaks.

Nombre:
URL:
Email:
Comentarios:
CAPTCHA Image Validation