Getting error 'to prevent exploits' when calling player in RTSNetworkManager

I am getting the below error.
I am using Mirror version 44.0.2.
Unity version 2020.3.10f1
This is happening when I try to call the player in RTSNetworkManager.
The below line works fine:

Then if I try to call:
player.SetDisplayName($“Player {Players.Count}”);
player.SetPartyOwner(Players.Count == 1);
I get the error.

This means I will either get the error when I try to host a lobby. I then can not start a game, as the conn.identity has been disconnected.

I wonder if I made an error in an earlier script that is causing this, but it seems to be built in to mirror to prevent exploits.

Disconnecting connId=0 to prevent exploits from an Exception in MessageHandler: NullReferenceException Object reference not set to an instance of an object
at RTSNetworkManager.OnServerAddPlayer (Mirror.NetworkConnection conn) [0x00029] in \Documents\UnityRepos\RealTimeStrategy\Assets\Scripts\Networking\RTSNetworkManager.cs:69
at Mirror.NetworkManager.OnServerAddPlayerInternal (Mirror.NetworkConnection conn, Mirror.AddPlayerMessage msg) [0x00060] in \Documents\UnityRepos\RealTimeStrategy\Assets\Mirror\Runtime\NetworkManager.cs:1128
at Mirror.MessagePacking+<>c__DisplayClass6_02[T,C].<WrapHandler>b__0 (Mirror.NetworkConnection conn, Mirror.NetworkReader reader, System.Int32 channelId) [0x0007a] in \\Documents\UnityRepos\RealTimeStrategy\Assets\Mirror\Runtime\MessagePacking.cs:118 UnityEngine.Debug:LogError (object) Mirror.MessagePacking/<>c__DisplayClass6_02<Mirror.AddPlayerMessage, Mirror.NetworkConnection>:b__0 (Mirror.NetworkConnection,Mirror.NetworkReader,int) (at Assets/Mirror/Runtime/MessagePacking.cs:122)
Mirror.NetworkServer:UnpackAndInvoke (Mirror.NetworkConnectionToClient,Mirror.NetworkReader,int) (at Assets/Mirror/Runtime/NetworkServer.cs:430)
Mirror.NetworkServer:OnTransportData (int,System.ArraySegment1<byte>,int) (at Assets/Mirror/Runtime/NetworkServer.cs:484) Mirror.LocalConnectionToServer:Send (System.ArraySegment1,int) (at Assets/Mirror/Runtime/LocalConnections.cs:88)
Mirror.NetworkConnection:Send<Mirror.AddPlayerMessage> (Mirror.AddPlayerMessage,int) (at Assets/Mirror/Runtime/NetworkConnection.cs:135)

Are these being called on the server or the client?

In RTSNetworkServer I have the following in #region Server. There is no signifier above it in square brackets.
I don’t have the color code as I will only be doing this for 2 players, and they will have preset colours.

public override void OnServerAddPlayer(NetworkConnection conn)
RTSPlayer player = conn.identity.GetComponent();


    Debug.Log("I'm getting to this method");
    player.SetDisplayName($"Player {Players.Count}");
    //Below is essentially an if statement checking if you have just 1 player now.
    //If so, that is the party owning player
    player.SetPartyOwner(Players.Count == 1);

Below is the relevant RTSPlayer code:

//The players name.
[SyncVar(hook = nameof(ClientHandleDisplayNameUpdated))]
private string displayName;

public void SetDisplayName(string displayName)

   //display name for this player is the name we just passed in
  this.displayName = displayName;

public void SetPartyOwner(bool state)
isPartyOwner = state;

I was concerned that I had not connected everything correctly in the gameobjects etc, but I can’t find anything that is missing.

Hi, can you add a couple debug.log statements to check for a null value?
see what happens if you log those in the console individually.