{"action":"created","issue":{"url":"https://api.github.com/repos/OfficeDev/Open-XML-SDK/issues/40","labels_url":"https://api.github.com/repos/OfficeDev/Open-XML-SDK/issues/40/labels{/name}","comments_url":"https://api.github.com/repos/OfficeDev/Open-XML-SDK/issues/40/comments","events_url":"https://api.github.com/repos/OfficeDev/Open-XML-SDK/issues/40/events","html_url":"https://github.com/OfficeDev/Open-XML-SDK/issues/40","id":75205584,"number":40,"title":"AddPart() throws Exception on Mono 4.0.0","user":{"login":"ThomasBarnekow","id":8481516,"avatar_url":"https://avatars.githubusercontent.com/u/8481516?v=3","gravatar_id":"","url":"https://api.github.com/users/ThomasBarnekow","html_url":"https://github.com/ThomasBarnekow","followers_url":"https://api.github.com/users/ThomasBarnekow/followers","following_url":"https://api.github.com/users/ThomasBarnekow/following{/other_user}","gists_url":"https://api.github.com/users/ThomasBarnekow/gists{/gist_id}","starred_url":"https://api.github.com/users/ThomasBarnekow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ThomasBarnekow/subscriptions","organizations_url":"https://api.github.com/users/ThomasBarnekow/orgs","repos_url":"https://api.github.com/users/ThomasBarnekow/repos","events_url":"https://api.github.com/users/ThomasBarnekow/events{/privacy}","received_events_url":"https://api.github.com/users/ThomasBarnekow/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-11T12:29:53Z","updated_at":"2015-07-05T21:22:13Z","closed_at":null,"body":"In one of my pull requests, I developed a `Clone()` method that clones `OpenXmlPackage` instances. For that purpose, it adds `OpenXmlPart` instances to the clone, using `AddPart(T, string)`.\r\n\r\nWhile this has worked nicely in production on Windows 7, doing the same using Mono 4.0.0 on Mac OS X Yosemite throws an exception:\r\n```\r\n[ERROR] FATAL UNHANDLED EXCEPTION: System.Xml.XmlException: Document element did not appear.  Line 1, position 1.\r\n  at Mono.Xml2.XmlTextReader.Read () [0x00000] in <filename unknown>:0 \r\n  at System.Xml.XmlTextReader.Read () [0x00000] in <filename unknown>:0 \r\n  at Mono.Xml.EntityResolvingXmlReader.Read () [0x00000] in <filename unknown>:0 \r\n  at Mono.Xml.DTDValidatingReader.ReadContent () [0x00000] in <filename unknown>:0 \r\n  at Mono.Xml.DTDValidatingReader.Read () [0x00000] in <filename unknown>:0 \r\n  at Mono.Xml.Schema.XsdValidatingReader.Read () [0x00000] in <filename unknown>:0 \r\n  at System.Xml.XmlValidatingReader.Read () [0x00000] in <filename unknown>:0 \r\n  at System.Xml.XmlDocument.ReadNodeCore (System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0 \r\n  at System.Xml.XmlDocument.ReadNode (System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0 \r\n  at System.Xml.XmlDocument.Load (System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0 \r\n  at System.Xml.XmlDocument.Load (System.IO.Stream inStream) [0x00000] in <filename unknown>:0 \r\n  at System.IO.Packaging.Package.LoadRelationships () [0x00000] in <filename unknown>:0 \r\n  at System.IO.Packaging.Package.get_Relationships () [0x00000] in <filename unknown>:0 \r\n  at System.IO.Packaging.Package.CreateRelationship (System.Uri targetUri, TargetMode targetMode, System.String relationshipType, System.String id, Boolean loading) [0x00000] in <filename unknown>:0 \r\n  at System.IO.Packaging.Package.CreateRelationship (System.Uri targetUri, TargetMode targetMode, System.String relationshipType, System.String id) [0x00000] in <filename unknown>:0 \r\n  at DocumentFormat.OpenXml.Packaging.OpenXmlPackage.CreateRelationship (System.Uri targetUri, TargetMode targetMode, System.String relationshipType, System.String id) [0x00000] in <filename unknown>:0 \r\n  at DocumentFormat.OpenXml.Packaging.OpenXmlPartContainer.AttachChild (DocumentFormat.OpenXml.Packaging.OpenXmlPart part, System.String rId) [0x00000] in <filename unknown>:0 \r\n  at DocumentFormat.OpenXml.Packaging.OpenXmlPartContainer.AddSubPartFromOtherPackage (DocumentFormat.OpenXml.Packaging.OpenXmlPart part, IDictionary`2 partDictionary, IDictionary`2 dataPartsDictionary, Boolean keepIdAndUri, System.String rId) [0x00000] in <filename unknown>:0 \r\n  at DocumentFormat.OpenXml.Packaging.OpenXmlPartContainer.AddSubPartFromOtherPackage (DocumentFormat.OpenXml.Packaging.OpenXmlPart part, Boolean keepIdAndUri, System.String rId) [0x00000] in <filename unknown>:0 \r\n  at DocumentFormat.OpenXml.Packaging.OpenXmlPartContainer.AddSubPart (DocumentFormat.OpenXml.Packaging.OpenXmlPart part, System.String rId) [0x00000] in <filename unknown>:0 \r\n  at DocumentFormat.OpenXml.Packaging.OpenXmlPartContainer.SetSubPart (DocumentFormat.OpenXml.Packaging.OpenXmlPart part, System.String rId) [0x00000] in <filename unknown>:0 \r\n  at DocumentFormat.OpenXml.Packaging.OpenXmlPartContainer.AddPartFrom (DocumentFormat.OpenXml.Packaging.OpenXmlPart subPart, System.String rId) [0x00000] in <filename unknown>:0 \r\n  at DocumentFormat.OpenXml.Packaging.OpenXmlPartContainer.AddPart[OpenXmlPart] (DocumentFormat.OpenXml.Packaging.OpenXmlPart part, System.String id) [0x00000] in <filename unknown>:0 \r\n  at DocumentFormat.OpenXml.Packaging.OpenXmlPackage.Clone (System.IO.Stream stream, Boolean isEditable, DocumentFormat.OpenXml.Packaging.OpenSettings openSettings) [0x00000] in <filename unknown>:0 \r\n  at DocumentFormat.OpenXml.Packaging.OpenXmlPackage.Clone () [0x00000] in <filename unknown>:0 \r\n```\r\nAs with the other issue related to opening a read-only `WordprocessingDocument` instance, this might be a Mono bug (and the exception message might not even be helpful). It also involves `System.IO.Packaging.Package.get_Relationships` and related methods. \r\n\r\nThe same questions arise: To what extent has the Open XML SDK been tested on Mono? Is there any workaround on the level of the Open XML SDK?"},"comment":{"url":"https://api.github.com/repos/OfficeDev/Open-XML-SDK/issues/comments/118668350","html_url":"https://github.com/OfficeDev/Open-XML-SDK/issues/40#issuecomment-118668350","issue_url":"https://api.github.com/repos/OfficeDev/Open-XML-SDK/issues/40","id":118668350,"user":{"login":"ThomasBarnekow","id":8481516,"avatar_url":"https://avatars.githubusercontent.com/u/8481516?v=3","gravatar_id":"","url":"https://api.github.com/users/ThomasBarnekow","html_url":"https://github.com/ThomasBarnekow","followers_url":"https://api.github.com/users/ThomasBarnekow/followers","following_url":"https://api.github.com/users/ThomasBarnekow/following{/other_user}","gists_url":"https://api.github.com/users/ThomasBarnekow/gists{/gist_id}","starred_url":"https://api.github.com/users/ThomasBarnekow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ThomasBarnekow/subscriptions","organizations_url":"https://api.github.com/users/ThomasBarnekow/orgs","repos_url":"https://api.github.com/users/ThomasBarnekow/repos","events_url":"https://api.github.com/users/ThomasBarnekow/events{/privacy}","received_events_url":"https://api.github.com/users/ThomasBarnekow/received_events","type":"User","site_admin":false},"created_at":"2015-07-05T21:22:13Z","updated_at":"2015-07-05T21:22:13Z","body":"@EricWhiteDev Have you tested your new implementation of System.IO.Packaging on Mono? Is this issue now fixed?"}}