[Mono-dev] System.IO.Packaging throws NullReferenceExeption

Alan alan.mcgovern at gmail.com
Thu Feb 9 20:22:02 UTC 2012


Hi,

For every testcase which fails, could you create a bug report on
http://bugzilla.xamarin.com, attach the testcase and assign it to "
alan at xamarin.com". I will look at them when I get a chance and fix the
underlying issues where possible. If you could also attach the resulting
'out.zip' created from the microsoft framework, that would make it faster
for me to ensure things are generated correctly.

Thanks!
Alan

On 9 February 2012 13:03, CikaPero1 <cika.pero1 at gmail.com> wrote:

> Hi,
>
> Does anyone know why the code below throws an exception?
>
> The code below works with MS Visual Studio but simply won't work with Mono
> 2.8.
>
> using System;
> using System.IO;
> using System.IO.Packaging;
> using System.Text;
> using System.Xml;
>
> namespace ConsoleApplication
> {
>    class Program
>    {
>        static void Main(string[] args)
>        {
>            using (Package Package = Package.Open("out.zip",
> FileMode.Create))
>            {
>                Uri partUri = new Uri("/_rels/.rels", UriKind.Relative);
>                PackagePart packagePart = Package.CreatePart(partUri,
> "application/vnd.openxmlformats-package.relationships+xml");
>
>                using (Stream str = packagePart.GetStream())
>                {
>                    using (var writer = new XmlTextWriter(str, new
> UTF8Encoding(false)))
>                    {
>                        writer.WriteStartDocument(true);
>                        writer.WriteStartElement("Relationships");
>                        writer.WriteAttributeString("xmlns",
> "http://schemas.openxmlformats.org/package/2006/relationships");
>                        writer.WriteStartElement("Relationship");
>                        writer.WriteAttributeString("Type",
> "
> http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties
> ");
>                        writer.WriteEndElement();
>                        writer.WriteEndElement();
>                    }
>                }
>            }
>        }
>    }
> }
>
> Strangely, it works when I change some strings:
> a) "/_rels/.rels" -> "/rels/.rels"
> b) or "xmlns" -> "x"
> c) or "http://schemas.openxmlformats.org/package/2006/relationships" ->
> "http://schemas.openxmlformats.org/package/2007/relationships"
> d) or "http://schemas.openxmlformats.org/package/2006/relationships" ->
> "http://schemas.openxmlformats.org/package/2007/relationships" and
> "
> http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties
> "
> ->
> "
> http://schemas.openxmlformats.org/package/2007/relationships/metadata/core-properties
> "
>
> This will bring me to insanity!
>
> Thanks for any help,
> Cika Pero
>
> --
> View this message in context:
> http://mono.1490590.n4.nabble.com/System-IO-Packaging-throws-NullReferenceExeption-tp4372735p4372735.html
> Sent from the Mono - Dev mailing list archive at Nabble.com.
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20120209/533f8548/attachment-0001.html>


More information about the Mono-devel-list mailing list