This one has me stumped.
I'm creating a ListViewWebPart, which ultimately inherits from System.Web.UI.Control which implements IDisposable. So ListViewWebPart should also be IDisposable. Right?
But when I code:
using ( ListViewWebPart webPart = new ListViewWebPart()) { ... }
I get a compile error that tells me this type can't be implicitly converted to IDisposable.
I just know I'm doing something wrong here but I just can't see it.
If I use the full class name Microsoft.SharePoint.WebPartPages.ListViewWebPart I still get the same error, and if I use the same code above without the using I can even see the .Dispose() method coming up in the intelli sense.
Could the Dispose() method be shadowed (new'ed) or something?
I'm using VS 2012 on SharePoint 2010 (so .Net 3.5 target).
I'll have a look with ILSPY but has anyone out there seen this before?
I guess my fall back is to explicitly do this with a try/finally.
(I must have been really bad in a previous life to end up as a SharePoint developer.)
Minor Update:
It might be something to do with the SharePoint project or where I'm using it (Feature Event Receiver Activation method). In a separate class library this works fine with no problem.