Reputation: 548
I'm developing a mobile application with Xamarin and getting an error when running it.
The error occurs very often but not always.
I'm testing it on Sumsung Galaxy S6.
The code that I am using (located in renderer):
new SvgReader(new StreamReader(svgStream),
new StylesParser(new ValuesParser()),
new ValuesParser());
Xamarin version:
Exception:
ERROR: System.MethodAccessException: Method `System.Xml.Linq.XContainer:ReadContentFrom (System.Xml.XmlReader)' is inaccessible from method `System.Xml.XmlReader:get_DtdInfo ()'
at (wrapper managed-to-native) System.Object:__icall_wrapper_mono_throw_method_access (intptr,intptr)
at System.Xml.Linq.XContainer.ReadContentFrom (System.Xml.XmlReader r) [0x001a0] in /Users/builder/data/lanes/3511/f4db8a57/source/mono/mcs/class/referencesource/System.Xml.Linq/System/Xml/Linq/XLinq.cs:3073
at System.Xml.Linq.XContainer.ReadContentFrom (System.Xml.XmlReader r, System.Xml.Linq.LoadOptions o) [0x00008] in /Users/builder/data/lanes/3511/f4db8a57/source/mono/mcs/class/referencesource/System.Xml.Linq/System/Xml/Linq/XLinq.cs:3090
at System.Xml.Linq.XDocument.Load (System.Xml.XmlReader reader, System.Xml.Linq.LoadOptions options) [0x0009b] in /Users/builder/data/lanes/3511/f4db8a57/source/mono/mcs/class/referencesource/System.Xml.Linq/System/Xml/Linq/XLinq.cs:5747
at System.Xml.Linq.XDocument.Load (System.IO.TextReader textReader, System.Xml.Linq.LoadOptions options) [0x0000f] in /Users/builder/data/lanes/3511/f4db8a57/source/mono/mcs/class/referencesource/System.Xml.Linq/System/Xml/Linq/XLinq.cs:5693
at System.Xml.Linq.XDocument.Load (System.IO.TextReader textReader) [0x00000] in /Users/builder/data/lanes/3511/f4db8a57/source/mono/mcs/class/referencesource/System.Xml.Linq/System/Xml/Linq/XLinq.cs:5666
at NGraphics.Custom.Parsers.SvgReader..ctor (System.IO.TextReader reader, NGraphics.Custom.Parsers.IStylesParser stylesParser, NGraphics.Custom.Parsers.IValuesParser valuesParser) [0x0001f] in <c787e3d8c9e842909bf317040008966c>:0
How do I solve the error?
Upvotes: 1
Views: 229
Reputation: 449
I kept getting the Method 'System.Xml.XmlReader:get_DtdInfo ()' is inaccessible
exception randomly until I removed all the extra cruft in the doctype and xmlns that gfx editors tend to put in there.
Before, my SVG files looked like this..
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
<!ENTITY ns_extend "http://ns.adobe.com/Extensibility/1.0/">
<!ENTITY ns_ai "http://ns.adobe.com/AdobeIllustrator/10.0/">
<!ENTITY ns_graphs "http://ns.adobe.com/Graphs/1.0/">
<!ENTITY ns_vars "http://ns.adobe.com/Variables/1.0/">
<!ENTITY ns_imrep "http://ns.adobe.com/ImageReplacement/1.0/">
<!ENTITY ns_sfw "http://ns.adobe.com/SaveForWeb/1.0/">
<!ENTITY ns_custom "http://ns.adobe.com/GenericCustomNamespace/1.0/">
<!ENTITY ns_adobe_xpath "http://ns.adobe.com/XPath/1.0/">]>
<svg version="1.1" id="Layer_1" xmlns:x="&ns_extend;" xmlns:i="&ns_ai;" xmlns:graph="&ns_graphs;"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="512px" height="512px" viewBox="0 0 512 512" enable-background="new 0 0 512 512" xml:space="preserve">
<metadata>
<sfw xmlns="&ns_sfw;">
<slices></slices>
<sliceSourceBounds width="427.66" height="361.922" x="42.17" y="-436.961" bottomLeftOrigin="true"></sliceSourceBounds>
</sfw>
</metadata>
<g>
...
But I trimmed out anything unnecessary looking until I got...
<?xml version="1.0" encoding="utf-8"?>
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="512px" height="512px" viewBox="0 0 512 512" enable-background="new 0 0 512 512" xml:space="preserve">
<g>
...
And the random crashes went away for me. Complex dtd/xmlns must freak the lib out.
Upvotes: 2
Reputation: 406
Bad news, this appears to be covered in the following Xamarin bugzilla posts:
Here is the Xamarin description for this exception.
https://developer.xamarin.com/api/type/System.MethodAccessException/
For now, I would advise implementing the work-around suggested in these forums to simply catch the exception and move on (sadly...).
Upvotes: 0