<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>Comments on: BinaryFormatter on iOS</title>
	<atom:link href="http://www.horsedrawngames.com/binaryformatter-on-ios/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.horsedrawngames.com/binaryformatter-on-ios/</link>
	<description>Horse Drawn Games</description>
	<lastBuildDate>Tue, 12 Jun 2018 14:36:54 +0000</lastBuildDate>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: Sam</title>
		<link>http://www.horsedrawngames.com/binaryformatter-on-ios/#comment-42</link>
		<dc:creator><![CDATA[Sam]]></dc:creator>
		<pubDate>Thu, 12 Mar 2015 13:29:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.horsedrawngames.com/?p=88#comment-42</guid>
		<description><![CDATA[I looked into this a bit. The BinaryFormatter (and other serialisers too, I assume) ends up calling an internal method in Generic.Dictionary called Do_CopyTo. It seems that for some reason Mono isn&#039;t able to generate the code for this method ahead-of-time, so instead it tries to generate it at runtime. Looking at Do_CopyTo, I can&#039;t see what would be confusing it. There&#039;s a delegate argument, but it has all the type information so in theory it should have everything it needs. I tried forcing the compiler to generate a concrete class to work around it but I just couldn&#039;t get it to generate it.

To work around this you can use the Collections.Hashtable instead of the generic dictionary. It&#039;s not as nice since it isn&#039;t type safe and you have to cast everywhere, but at least it works.

I thought the issue might have been the nested generics, but replacing the List&lt;&gt; with an ArrayList doesn&#039;t help.]]></description>
		<content:encoded><![CDATA[<p>I looked into this a bit. The BinaryFormatter (and other serialisers too, I assume) ends up calling an internal method in Generic.Dictionary called Do_CopyTo. It seems that for some reason Mono isn&#8217;t able to generate the code for this method ahead-of-time, so instead it tries to generate it at runtime. Looking at Do_CopyTo, I can&#8217;t see what would be confusing it. There&#8217;s a delegate argument, but it has all the type information so in theory it should have everything it needs. I tried forcing the compiler to generate a concrete class to work around it but I just couldn&#8217;t get it to generate it.</p>
<p>To work around this you can use the Collections.Hashtable instead of the generic dictionary. It&#8217;s not as nice since it isn&#8217;t type safe and you have to cast everywhere, but at least it works.</p>
<p>I thought the issue might have been the nested generics, but replacing the List<> with an ArrayList doesn&#8217;t help.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yuriy</title>
		<link>http://www.horsedrawngames.com/binaryformatter-on-ios/#comment-41</link>
		<dc:creator><![CDATA[Yuriy]]></dc:creator>
		<pubDate>Thu, 12 Mar 2015 07:35:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.horsedrawngames.com/?p=88#comment-41</guid>
		<description><![CDATA[Hi, and thank you for a response. The type I&#039;m storing in the List is from a class I made. The dictionary definition looks like this : Dictionary&lt;string, List&gt;, where Upgrade data is :
[Serializable]
public class UpgradeData
{
   public bool lockStatus;
   public bool purchased;
 
}
and then the class that handles the Dictionary looks like this:
[Serializable]
    public class CharacterUpgradeList
    {

        private UpgradeData[] _upgrade_Data;
        private List[] upgData;
        
        public Dictionary&lt;string, List&gt; upgradeList;
        public CharacterUpgradeList()
        {
            upgData = new List[4];
            for (int i = 0; i &lt; upgData.Length; i++)
            {
                upgData[i] = new List { 
                        new UpgradeData(),
                        new UpgradeData(),
                        new UpgradeData(),
                        new UpgradeData(),
                        new UpgradeData(),
                        new UpgradeData()
                   };
            }

            upgradeList = new Dictionary&lt;string, List&gt;
        {
            {&quot;Man&quot;,upgData[0]},
            {&quot;Woman&quot;,upgData[1]},
            {&quot;Boy&quot;,upgData[2]},
            {&quot;Girl&quot;,upgData[3]}
            
        };
        }
    }]]></description>
		<content:encoded><![CDATA[<p>Hi, and thank you for a response. The type I&#8217;m storing in the List is from a class I made. The dictionary definition looks like this : Dictionary&lt;string, List&gt;, where Upgrade data is :<br />
[Serializable]<br />
public class UpgradeData<br />
{<br />
   public bool lockStatus;<br />
   public bool purchased;</p>
<p>}<br />
and then the class that handles the Dictionary looks like this:<br />
[Serializable]<br />
    public class CharacterUpgradeList<br />
    {</p>
<p>        private UpgradeData[] _upgrade_Data;<br />
        private List[] upgData;</p>
<p>        public Dictionary&lt;string, List&gt; upgradeList;<br />
        public CharacterUpgradeList()<br />
        {<br />
            upgData = new List[4];<br />
            for (int i = 0; i &lt; upgData.Length; i++)<br />
            {<br />
                upgData[i] = new List {<br />
                        new UpgradeData(),<br />
                        new UpgradeData(),<br />
                        new UpgradeData(),<br />
                        new UpgradeData(),<br />
                        new UpgradeData(),<br />
                        new UpgradeData()<br />
                   };<br />
            }</p>
<p>            upgradeList = new Dictionary&lt;string, List&gt;<br />
        {<br />
            {&#8220;Man&#8221;,upgData[0]},<br />
            {&#8220;Woman&#8221;,upgData[1]},<br />
            {&#8220;Boy&#8221;,upgData[2]},<br />
            {&#8220;Girl&#8221;,upgData[3]}</p>
<p>        };<br />
        }<br />
    }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sam</title>
		<link>http://www.horsedrawngames.com/binaryformatter-on-ios/#comment-40</link>
		<dc:creator><![CDATA[Sam]]></dc:creator>
		<pubDate>Thu, 12 Mar 2015 07:16:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.horsedrawngames.com/?p=88#comment-40</guid>
		<description><![CDATA[I&#039;m not exactly sure. There&#039;s evidently some other part of Mono that is trying to generate code to perform the serialisation. Are you getting the &quot;Attempting to JIT compile method&quot; exception? What types are you storing in your List in the Dictionary?]]></description>
		<content:encoded><![CDATA[<p>I&#8217;m not exactly sure. There&#8217;s evidently some other part of Mono that is trying to generate code to perform the serialisation. Are you getting the &#8220;Attempting to JIT compile method&#8221; exception? What types are you storing in your List in the Dictionary?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yuriy</title>
		<link>http://www.horsedrawngames.com/binaryformatter-on-ios/#comment-39</link>
		<dc:creator><![CDATA[Yuriy]]></dc:creator>
		<pubDate>Thu, 12 Mar 2015 07:03:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.horsedrawngames.com/?p=88#comment-39</guid>
		<description><![CDATA[Hi. Using this tip helped me serialize all my objects on a Ios device. But recently I had to add a Dictionary data structure to my project. It is the flowing: Dictionary&lt;string, List&gt;. This does not serialize on Ios and fires a JIT exception. Why is this happening and how can I get around it ?]]></description>
		<content:encoded><![CDATA[<p>Hi. Using this tip helped me serialize all my objects on a Ios device. But recently I had to add a Dictionary data structure to my project. It is the flowing: Dictionary&lt;string, List&gt;. This does not serialize on Ios and fires a JIT exception. Why is this happening and how can I get around it ?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
