Invalid Cast Exception when joining room

Support for MFPS 2.0 (for verified users)
Forum rules
To request support/assistance for MFPS, you first have to verify your purchase by sending your purchase invoice number to Lovatto in a PM.
Post Reply
User avatar
thejimone
Contributor
Contributor
Posts: 4
Joined: Sun Nov 29, 2020 6:46 am

Hello,
I've been workin gwith MFPS recently and everything worked perfectly when testing with bots! When I started testing with actual multiplayer a problem occured... The one that tries to join a room gets an error... Any help is appreciated... Thank you!

Code: Select all

InvalidCastException: Specified cast is not valid.
bl_WaitingRoom.OnEventCustom (ExitGames.Client.Photon.EventData data) (at Assets/MFPS/Scripts/Network/Waiting Room/bl_WaitingRoom.cs:164)
Photon.Realtime.LoadBalancingClient.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:3215)
ExitGames.Client.Photon.PeerBase.DeserializeMessageAndCallback (ExitGames.Client.Photon.StreamBuffer stream) (at <93d7bfaf6a774f5fac24d79468df113d>:0)
ExitGames.Client.Photon.EnetPeer.DispatchIncomingCommands () (at <93d7bfaf6a774f5fac24d79468df113d>:0)
ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands () (at <93d7bfaf6a774f5fac24d79468df113d>:0)
Photon.Pun.PhotonHandler.Dispatch () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:223)
Photon.Pun.PhotonHandler.FixedUpdate () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:149)
User avatar
Lovatto
Admin
Admin
Posts: 1834
Joined: Sun Dec 07, 2014 3:18 pm
Contact:

Hi,

Seems like you have made some changes in bl_WaitingRoom.cs,
send me your MFPS purchase number and a PM and post here the line 164 of your bl_WaitingRoom.cs script after.
How to find your Invoice Number: Here
How to find your Order Number: Here
User avatar
thejimone
Contributor
Contributor
Posts: 4
Joined: Sun Nov 29, 2020 6:46 am

This is line 164:

Code: Select all

HashTable t = (HashTable)data.CustomData;
User avatar
Lovatto
Admin
Admin
Posts: 1834
Joined: Sun Dec 07, 2014 3:18 pm
Contact:

Try changing that line with:

Code: Select all

ExitGames.Client.Photon.Hashtable t = (ExitGames.Client.Photon.Hashtable)data.CustomData;
if it doesn't work, send me your bl_WaitingRoom.cs script in a PM.
How to find your Invoice Number: Here
How to find your Order Number: Here
User avatar
Lovatto
Admin
Admin
Posts: 1834
Joined: Sun Dec 07, 2014 3:18 pm
Contact:

I check your code, I din't found any sustancial difference, but still I was not able to replicate the issue,
so I'll need a little more information from your side.

- First, enumerate the steps that you do before the error appears.
- Add this line:

Code: Select all

  Debug.Log($"Parameter type: {data.CustomData.GetType()} - {data.CustomData is ExitGames.Client.Photon.Hashtable}");
After these lines: (start at line 163 in your script).

Code: Select all

public void OnEventCustom(EventData data)
    {
    
And after you test, check the console and try to find the log "Parameter type: ..." and post it here.
How to find your Invoice Number: Here
How to find your Order Number: Here
User avatar
Lovatto
Admin
Admin
Posts: 1834
Joined: Sun Dec 07, 2014 3:18 pm
Contact:

I was able to replicated the issue with the latest version of Photon PUN,
You can fix it by adding this line:

Code: Select all

if (data.CustomData == null) return;
Right after these lines: (hint-line 160)

Code: Select all

public void OnEventCustom(EventData data)
    {
How to find your Invoice Number: Here
How to find your Order Number: Here
User avatar
thejimone
Contributor
Contributor
Posts: 4
Joined: Sun Nov 29, 2020 6:46 am

Thank you so much for your help! It kinda works... The error still pops up but at least now the game is playable!
Post Reply