Unity-Technologies/UnityCsReference · error · ArgumentException
Can not be Guid.Empty
Error message
Can not be Guid.Empty
What it means
Thrown by EditorConnection.Send(messageId, data, playerId) when messageId is Guid.Empty. Same invariant as Register: every sent message must carry a valid identifier so the player can route it.
Source
Thrown at Editor/Mono/Networking/PlayerConnection/EditorConnection.cs:156
{
m_PlayerEditorConnectionEvents.disconnectionEvent.AddPersistentListener(callback, UnityEventCallState.EditorAndRuntime);
}
public void UnregisterConnection(UnityAction<int> callback)
{
m_PlayerEditorConnectionEvents.connectionEvent.RemovePersistentListener((UnityEngine.Object)callback.Target, callback.Method);
}
public void UnregisterDisconnection(UnityAction<int> callback)
{
m_PlayerEditorConnectionEvents.disconnectionEvent.RemovePersistentListener((UnityEngine.Object)callback.Target, callback.Method);
}
public void Send(Guid messageId, byte[] data, int playerId)
{
if (messageId == Guid.Empty)
{
throw new ArgumentException("Can not be Guid.Empty", "messageId");
}
GetEditorConnectionNativeApi().SendMessage(messageId, data, playerId);
}
public void Send(Guid messageId, byte[] data)
{
Send(messageId, data, 0);
}
public bool TrySend(Guid messageId, byte[] data, int playerId)
{
if (messageId == Guid.Empty)
{
throw new ArgumentException("Can not be Guid.Empty", "messageId");
}
return GetEditorConnectionNativeApi().TrySendMessage(messageId, data, playerId);View on GitHub (pinned to 225b0fbdb5)
Solutions
- Use the same non-empty message Guid used at registration time.
- Guard with a check or use TrySend which also validates (and returns false rather than throwing only on the native side).
- Centralize message IDs in a shared constants class.
Example fix
// before connection.Send(Guid.Empty, bytes, playerId); // after connection.Send(k_MsgId, bytes, playerId);
Defensive patterns
Strategy: validation
Validate before calling
if (messageId != Guid.Empty) connection.Send(messageId, data, playerId);
Type guard
static bool IsValidMessageId(Guid id) => id != Guid.Empty;
Prevention
- Reuse the same Guid registered at subscription time.
- Centralize message IDs in a shared constants class.
When it happens
Trigger: Calling Send with a default/uninitialized Guid, or a messageId variable that was never set.
Common situations: Sending before subscribing to a known message ID; hardcoded empty Guid in test code; message-ID constant refactored away.
Related errors
- Cant be Guid.Empty
- Cannot add source dependency on empty GUID.
- Cannot add artifact dependency on empty GUID.
- Platform GUID {platformGuid} is not a valid Unity build plat
- Couldn't locate scene asset at path {scenePath}
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/5359af80903515c9.
Report an issue: GitHub.