How do you serialize a UGameInstance object?

Some context about what I’m trying to do first: I am trying to do the migration of the whole game state (game instance, player, worlds, etc.) from one running game process to another. These game processes will be running in different virtual machines.

The first thing I am trying to do is to serialize the UGameInstance object that is created and called in GameEngine.cpp. I have been trying many methods, but all of them had some sort of error or problem with it.

So far, I have tried this:

This one Crashes when serializing using “<<”. The callstack brings me this inside MemoryArchive.h

virtual FArchive& operator<<( class UObject*& Res ) override
{
	// Not supported through this archive
	check(0);
	return *this;
}

Does this mean that it’s impossible to serialize a UGameInstance via Unreal’s “<<” operator?

Next one I tried:

This one seems to be the best one so far. Everything works until the point where I call GameInstance->StartGameInstance(). I am told that there is a read access exception. My guess is that *FileReader << GameInstance does not seem to be loading properly. Why though?

Next one I tried:

This one fails at FMemoryReader MemoryReader(GameInstance, true);. During compilation, cannot convert argument 1 from 'UGameInstance *' to 'const TArray &' is shown. Is this another sign that UGameInstance cannot be serialized?

So is it really not possible to serialize UGameInstance? If it really is not possible, considering the context of what I was doing, are there any ideas of how else I can achieve this?

What is the best way to handle Saving/Loading an Array of Objects? - Programming & Scripting - Epic Developer Community Forums

The last try u’ve mentioned will work just fine, when filling in the correct type of param.
In ur case, maybe like:

TArray<uint8> binaryData;  
FMemoryReader MemoryReader(binaryData, true); 
FObjectAndNameAsStringProxyArchive wrapperAr = FObjectAndNameAsStringProxyArchive(MemoryReader, false);
gameInstance->Serialize(wrapperAr);   //or something else u need

Can you not serialize everything ?
I know you are trying to serialize the whole game and send it but just like when you save a game, you don’t serialize everything.
A lot of internal things are happening and they don’t really matter to you I’m guessing.
I would recommend to save and serialize in your own class or struct only what you need. If you feel like you need “everything” you will need to save every UObject in the current level and all important data in other part of the game but you don’t need to serialize every little things.
It’s like a multiplayer game, you could send everything but in the end you send some things and the rest can be comes from those things.