twintechs / TwinTechsFormsLib

Apache License 2.0
193 stars 73 forks source link

Getting "System.NotSupportedException: Path Operation c" when trying to load a SVG #49

Open Firlefanz opened 8 years ago

Firlefanz commented 8 years ago

Hello,

Thanks a lot for your library :-)

I was using Xam.Plugins.Forms.Svg before. But it often throws a get_DtdInfo error and is not stable and no issue answered. So I found your library here and tried to use it for my Project.

My Project is an existing xamarin shared Project. In order to have all resources in one place I added an additional pcl assembly. In this one I added my resources (svg).

Each time I try to use it in xaml I get an error here in your SVGImage.cs LoadSvgFromResource: var r = new SvgReader(new StreamReader(svgStream)); raises the exception "System.NotSupportedException: Path Operation c".

All my svg Images are added to the additional assembly as embedded Content. It worked in the other SVG. The Xaml Looks like this:

Binding SVGAssembly holds the additional assembly with all resources. SVGImage binds to a complete path to the additional assembly like "MyClient_Resources.Resources.Icons.ic_call_48px.svg".

Any idea what's wrong? I am using the free SVG Images from Google "Material-design-icons-1.0.0".

Thanks a lot!

Firlefanz commented 8 years ago

I tried to remove the additional assembly Name from all resources names in the xaml (at the beginning).

"Resources.Icons.ic_call_48px.svg"

I then get the error message: System.Exception: Error retrieving Resources.Icons.ic_call_48px.svg make sure Build Action is Embedded Resource

It is Embedded Resource, I think it just cannot be found now.

Firlefanz commented 8 years ago

Or is it the SVG I am using? It is one of the free Google SVGs:

Firlefanz commented 8 years ago

If I copy your Logo SVG into my SVG it works. Any Change to get it working with the Standard Google SVGs? Or what do I have to Change in the SVG?

Thanks a lot :-)

runelkrone commented 8 years ago

I am getting this also with Android svg images. It appears to be coming from NGraphics.

{System.NotSupportedException: Path Operation c at NGraphics.SvgReader.ReadPath (NGraphics.Path p, System.String pathDescriptor) [0x00466] in :0 at NGraphics.SvgReader.AddElement (IList1 list, System.Xml.Linq.XElement e, NGraphics.Pen inheritPen, NGraphics.Brush inheritBrush) [0x00553] in <filename unknown>:0 at NGraphics.SvgReader.AddElements (IList1 list, IEnumerable`1 es, NGraphics.Pen inheritPen, NGraphics.Brush inheritBrush) [0x00013] in :0 at NGraphics.SvgReader.Read (System.Xml.Linq.XDocument doc) [0x0018f] in :0 at NGraphics.SvgReader..ctor (System.IO.TextReader reader, Double pixelsPerInch) [0x0007a] in :0 at ... }

johnnysbug commented 8 years ago

This is likely because the underlying NGraphics version does not support SVGO, which is unfortunate. As a workaround, if you're on a mac and have Sketch, you can open existing svg files and export them as svg, and these will work with the current version of NGraphics.