No Overload Error on debug

Coordinator
Aug 30, 2010 at 6:03 PM

Hello,

I followed your video tutorial and am trying to do an Xbox Debug with the Level file loaded and the Gleed2d using statement in place. I get the following Error:

No overload for method 'ChangeType' takes '2' arguments

This comes from the Level.cs file, Line 395.

Thanks for the help,

Adam

 

--------------------------------------------------------------------
This post/conversation was originally located at the old gleed2d forums and was moved here in September 2010 by the project coordinator, zissakos.
--------------------------------------------------------------------

Coordinator
Aug 30, 2010 at 6:04 PM

Hi Adam,

I have not tried this yet, but I will look into that in the near future.

Anybody else having the same issue?

 

Jan 21, 2012 at 6:34 PM

I'm not sure if this has been solved, but I just discovered Gleed2D today.  I'm also getting this error.

Jan 21, 2012 at 6:49 PM

Okay, I'm not sure if this solution will work but I managed to fix the compile time error.  Convert.ChangeType requires a third parameter of type IFormatProvider.  So I created the following class:

public class InterceptProvider : IFormatProvider
    {
        public object GetFormat(Type formatType)
        {
            if (formatType == typeof(string))
            {
               return typeof(string);
            }
            else if (formatType == typeof(Vector2))
            {
               return typeof(Vector2);
            }
            else if (formatType == typeof(bool))
            {
                return typeof(bool);
            }
            else if (formatType == typeof(Item))
            {
                return typeof(Item);
            }
            else if (formatType == typeof(Color))
            {
                return typeof(Color);
            }
            else
            {
                return null;
            }
        }
    }

I also modified the ReadXml method to the following: (Changes in red)

public void ReadXml(System.Xml.XmlReader reader)
        {

            bool wasEmpty = reader.IsEmptyElement;
            reader.Read();

            if (wasEmpty) return;

            IFormatProvider provider = new InterceptProvider();

            while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
            {
                CustomProperty cp = new CustomProperty();
                cp.name = reader.GetAttribute("Name");
                cp.description = reader.GetAttribute("Description");

                string type = reader.GetAttribute("Type");
                if (type == "string") cp.type = typeof(string);
                if (type == "bool") cp.type = typeof(bool);
                if (type == "Vector2") cp.type = typeof(Vector2);
                if (type == "Color") cp.type = typeof(Color);
                if (type == "Item") cp.type = typeof(Item);

                if (cp.type == typeof(Item))
                {
                    cp.value = reader.ReadInnerXml();
                    this.Add(cp.name, cp);
                }
                else
                {
                    reader.ReadStartElement("Property");
                    XmlSerializer valueSerializer = new XmlSerializer(cp.type);
                    object obj = valueSerializer.Deserialize(reader);
                    cp.value = Convert.ChangeType(obj, cp.type, provider);
                    this.Add(cp.name, cp);
                    reader.ReadEndElement();
                }

                reader.MoveToContent();
            }
            reader.ReadEndElement();
        }
From there, I was able to compile and get passed that error.  I'm in the process of testing this right now.
Jan 21, 2012 at 7:00 PM

Hrm...hold for a few.  Coming across some runtime errors now.  Will post again until I figure it out.

Jan 21, 2012 at 7:27 PM

Actually, this solution worked.  My runtime error was due to the fact that I didn't change the way the game opened the file because I'm trying to run it on the Windows Phone.

Jan 22, 2012 at 12:56 PM
Hi,
I've been working on the next version of Gleed 2D. There's now a completely new way of loading levels, so this issue has likely been resolved.

If there is an issue, do let me know.

Cheers,

Steve

On 21 January 2012 20:27, KahunaCoder <notifications@codeplex.com> wrote:

From: KahunaCoder

Actually, this solution worked. My runtime error was due to the fact that I didn't change the way the game opened the file because I'm trying to run it on the Windows Phone.

Read the full discussion online.

To add a post to this discussion, reply to this email (gleed2d@discussions.codeplex.com)

To start a new discussion for this project, email gleed2d@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Jan 22, 2012 at 4:35 PM
Edited Jan 22, 2012 at 5:07 PM

Hi Steve.  Thanks!  I'll check it out for sure. :)

Jan 22, 2012 at 5:51 PM
Great, I'm glad someone's using it! Do let me know if there's any issues. I'm actively working on it 'till it's stable and/or other people in the community start contributing to it.

All the best,

Steve.

On 22 January 2012 17:35, KahunaCoder <notifications@codeplex.com> wrote:

From: KahunaCoder

Hi Steve,

First of all, thanks for putting the time and effort with this awesome tool! I've been playing around with this all morning long and am convinced I need to use this for a side project I've been working on. Although I need to integrate and change things around, I think in the end, it'll be worth the effort.

I'm very excited to have found this tool! Again, thanks!

Rey

Read the full discussion online.

To add a post to this discussion, reply to this email (gleed2d@discussions.codeplex.com)

To start a new discussion for this project, email gleed2d@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com