Compiling against OpenXml v2.0.50727

Dec 6, 2010 at 8:54 PM

I get build errors comiling agains 2.0.

Error 1 The type 'DocumentFormat.OpenXml.Packaging.CustomXmlPart' cannot be used as type parameter 'T' in the generic type or method 'DocumentFormat.OpenXml.Packaging.OpenXmlPartContainer.AddNewPart<T>()'. There is no implicit reference conversion from 'DocumentFormat.OpenXml.Packaging.CustomXmlPart' to 'DocumentFormat.OpenXml.Packaging.IFixedContentTypePart'. C:\Projects\Open XML PowerShell Tools\Classes\CustomXmlAccessor.cs 63 33 OpenXml Power Tools
and

Error 2 The type 'DocumentFormat.OpenXml.Packaging.CustomXmlPart' cannot be used as type parameter 'T' in the generic type or method 'DocumentFormat.OpenXml.Packaging.OpenXmlPartContainer.AddNewPart<T>()'. There is no implicit reference conversion from 'DocumentFormat.OpenXml.Packaging.CustomXmlPart' to 'DocumentFormat.OpenXml.Packaging.IFixedContentTypePart'. C:\Projects\Open XML PowerShell Tools\Classes\DocumentBuilder.cs 956 45 OpenXml Power Tools

Has anyone done this?

M

Dec 9, 2010 at 8:05 PM

Hi Matt, I'm getting the same compilation error. Have you figured out a solution to this?

Thanks

Shan

Dec 9, 2010 at 8:17 PM

It looks like the Open XML APIs have been updated since the source code for this project was released. I was able to find a suggested change for this compilation error at http://social.msdn.microsoft.com/Forums/en-US/oxmlsdk/thread/95db2ea1-aa48-4b7d-99ae-86b3bad1bdd2/ although I'm not sure if the functional behaviour of the API will work as expected. The change that I made to the lines of source that were not compiling follows:

            if (customXmlPart == null)
                customXmlPart = parentDocument.Document.MainDocumentPart.AddCustomXmlPart(CustomXmlPartType.CustomXml);