OpenXML SDK 2.0 snippet problem – XLInsertCustomXML

very much appreciate any help and guidance anyone can lend.

i’m trying to use the OpenXML SDK 2.0’s XLInsertCustomXml snippet in a C# VS2008 project.  Upon adding the snippet, I receive one error associated with “wbPart.AddNewPart()” which reads:

The type ‘DocumentFormat.OpenXml.Packaging.CustomXmlPart’ cannot be used as type parameter ‘T’ in the generic type or method ‘DocumentFormat.OpenXml.Packaging.OpenXmlPartContainer.AddNewPart()’.  There is no implicit reference conversion from
‘DocumentFormat.OpenXml.Packaging.CustomXmlPart’ to ‘DocumentFormat.OpenXml.Packaging.IFixedContentTypePart’.

Does anyone know why this SDK snippet is dysfunctional and how to correct the error?


Are you trying to add CustomXML to a document, if that’s so there has been a change in how you do it I think. Instead of using AddNewPart you use AddCustomXmlPart(XElement custompart). Here is a code example: publicvoid insertXml(XElement customXml)

It would be nice if the on-line documentation was changed to reflect this — took me many hours to find this … 

Does anyone know of an acutal working sample? I only see snippets and the sample that I found does not seem to work.Thanks,