The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

Caught exception in OnEvent() for event code 200:

eligolf
2021-11-05 11:16:46

Hi,

Thank you for an awesome product, love it so far! I am having some weird issues with RPC calls however and I constantly (and sort of randomly?) get the following error message when playing with 3 players:

Caught exception in OnEvent() for event code 200: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.

It happens when I call my RPC function as per below which handles when a player finishes the hole in my minigolf game and lets all other player know it happened:

playerObjectsInGame is how many players who are still playing the hole and havent finished. I go through the objects and see if I found the sending person. If I did, I set some parameters and then remove from the list of gameobjects. Lastly I check if the hole ended (if the list of playerObjectsInGame is <= 0.

Why is the error occuring? I have googled a lot but can't find any relevant reasons. Am I doing something wrong?

Comments

[Deleted User]
2021-11-12 16:05:13

Hello,

An exception was thrown in your RPC function. Check for any NullRefException, especially in your following lines :

eligolf
2021-11-13 07:56:14

Thanks Clemanza, I didn't know it was a null reference. That makes it easier to debug :)

maxclark
2023-01-30 23:28:56

Is there any better way of getting a stack trace from Photon rather than ust "somewhere in the excecution of this RPC there's a exception"?

Sometimes, my RPCs have large bodies and pinpointing where the null reference is is a headahce.

If I wrap the code in a try-block, then I get the line number for the source of the exception, but I don't want to have to wrap all my RPCs in try-catch blocks.

Back to top