Page 1 of 3 123 LastLast
Results 1 to 10 of 30

Thread: Console Client

  1. #1
    Join Date
    Nov 2006
    Location
    Vancouver, WA
    Posts
    236

    Console Client

    Ok I am stuck I when I run he console client in debug mode I get the following errors.
    I have checked my code against the videos from the start of the console project many times now.

    This is in Visual Studio Debug
    Additional information: Unable to cast object of type 'System.String' to type 'System.Byte[]'.

    This is in the console not Debug
    Unhandled Exception: System.InvalidCastException: Unable to cast object of type 'System.String' to type 'System.Byte[]'.
    at MMO.Client.Systems.SystemsEventReader.SyncSystemsC omponentMap(EventCode code, Dictionary`2 parameters)
    in C:\src\MMO.Client\Systems\SystemsEventReader.cs:li ne 61

    at MMO.Client.Infrastructure.ClientTransportBase.Hand leEvent(EventCode code, Dictionary`2 parameters)
    in C:\src\MMO.Client\Infrastructure\ClientTransportBa se.cs:line 79

    at MMO.Client.Infrastructure.PhotonClientTransport.Ex itGames.Client.Photon.IPhotonPeerListener.OnEvent( EventData eventData)
    in C:\src\MMO.Client\Infrastructure\PhotonClientTrans port.cs:line 41

    at ExitGames.Client.Photon.PeerBase.DeserializeMessag eAndCallback(Byte[] inBuff)
    at ExitGames.Client.Photon.EnetPeer.DispatchIncomingC ommands()
    at ExitGames.Client.Photon.PhotonPeer.DispatchIncomin gCommands()
    at ExitGames.Client.Photon.PhotonPeer.Service()
    at MMOFramework.Client.Infrastructure.PhotonClientTra nsport.Service()
    in C:\src\MMO.Client\Infrastructure\PhotonClientTrans port.cs:line 31

    at MMO.Client.Console.Program.Main()
    in C:\src\MMO.Client.Console\Program.cs:line 23
    The only way to fail is to give up or die...

  2. #2
    Join Date
    Aug 2016
    Posts
    2
    Thanks, exactly what I needed.

  3. #3
    Join Date
    Nov 2006
    Location
    Vancouver, WA
    Posts
    236
    Click image for larger version. 

Name:	Debug1.png 
Views:	115 
Size:	104.3 KB 
ID:	74649 Screen Shot
    The only way to fail is to give up or die...

  4. #4
    Join Date
    Feb 2014
    Posts
    277
    I see the code eventually refers back to a photon engine call.
    What version of Photon are you using?
    The code snippet you provided matches mine perfectly, but I am using photon-3-4-30 still.

  5. #5
    Join Date
    Nov 2006
    Location
    Vancouver, WA
    Posts
    236
    Quote Originally Posted by oldngrey View Post
    I see the code eventually refers back to a photon engine call.
    What version of Photon are you using?
    The code snippet you provided matches mine perfectly, but I am using photon-3-4-30 still.
    I am also using 3-4-30
    The only way to fail is to give up or die...

  6. #6
    Join Date
    Feb 2014
    Posts
    277
    Only a couple of thoughts here.

    EventReaderModuleRegistration.cs
    Code:
    using System;
    using System.Collections.Generic;
    using BuzzMMO.Base;
    
    namespace BuzzMMO.Client.Infrastructure
    {
        public class EventReaderModuleRegistration
        {
            public EventCode Code { get; private set; }
            public Action<EventCode, Dictionary<byte, object>> Action { get; private set; }
    
            public EventReaderModuleRegistration(EventCode code, Action<EventCode, Dictionary<byte, object>> action)
            {
                Code = code;
                Action = action;
            }
        }
    }
    EventCode.cs
    Code:
    namespace BuzzMMO.Base
    {
        public enum EventCode : byte
        {
            SyncSystemsComponentMap,
            AddSystem,
            RemoveSystem,
            InvokeMethodOnSystem
        }
    }
    at the top of SystemsEventReader.cs
    Code:
           public IEnumerable<EventReaderModuleRegistration> GetRegistration()
            {
                return new[]
                {
                    new EventReaderModuleRegistration(EventCode.InvokeMethodOnSystem, InvokeMethodOnSystemEvent),
                    new EventReaderModuleRegistration(EventCode.AddSystem, AddSystemEvent),
                    new EventReaderModuleRegistration(EventCode.RemoveSystem, RemoveSystemEvent),
                    new EventReaderModuleRegistration(EventCode.SyncSystemsComponentMap, SyncSystemsComponentMap)
                };
            }
    The rest of the calls appear to be inside photon. That's why I mentioned it earlier.
    You know it's got to be a typo somewhere
    Last edited by oldngrey; 08-30-2016 at 12:58 AM.

  7. #7
    Join Date
    Nov 2006
    Location
    Vancouver, WA
    Posts
    236
    Mine looks like yours except it looks like you have EventCode outside of the Infrastructure namespace.
    The only way to fail is to give up or die...

  8. #8
    Join Date
    Feb 2014
    Posts
    277
    Maybe Nelson moved the files around later. My EventCode.cs is in the root of the Base project.
    What my quoting failed to do was where I'd like to highlight in red wherever it said byte. Trying to stuff a string into a byte parameter is what you need to be checking at every point.

    Another area I'd be looking at would be following through in SystemsEventReader.cs and seeing what sort of array was created in GetRegistration as quoted above. Set a breakpoint in program.cs
    maybe even near the start. It would be interesting to see where the string is stuffed into the array where the SyncSystemsComponentMap method expects a byte.
    Last edited by oldngrey; 09-01-2016 at 01:45 AM.

  9. #9
    Join Date
    Aug 2016
    Posts
    2
    Maybe Nelson moved the files around later. My EventCode.cs is in the root of the Base project.
    What my quoting failed to do was where I'd like to highlight in red wherever it said byte. Trying to stuff a string into a byte parameter is what you need to be checking at every point.

    Another area I'd be looking at would be following through in SystemsEventReader.cs and seeing what sort of array was created in GetRegistration as quoted above.
    Is it possible to scrape private proxies

  10. #10
    Join Date
    Nov 2006
    Location
    Vancouver, WA
    Posts
    236
    OldnGrey, thank you for your help. I am not very good at debugging code and just learning the process.

    My day job has put us into mandatory overtime, so I will not be able to work hard on this until 9/7.
    But I really do thank you very much for your advice.


    MJ Trottier
    Who is also OLD and GREY as you.....
    The only way to fail is to give up or die...

Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •