Download

[Solved] Build error (.NET unable to load type) on upgrading 4.XX projects to 5

Posting solution here since I saw folks on both the subreddit and discord struggling with this when upgrading projects without a solution.

The issue in question is noticed when upgrading an existing 4.2X project to 5, the issue will show up as build error for the UBT as follows:

UnrealBuildTool: Warning  : Unable to read hot reload state file: <project>\Intermediate\Build\Win64\EcEditor\Development\HotReload.state
UnrealBuildTool: Error  : System.Runtime.Serialization.SerializationException: Unable to load type System.Collections.Generic.Dictionary`2[[Tools.DotNETCommon.FileReference, DotNETUtilities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null],[Tools.DotNETCommon.FileReference, DotNETUtilities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null]] required for deserialization.
                           at System.Runtime.Serialization.ObjectManager.CompleteObject(ObjectHolder holder, Boolean bObjectFullyComplete)
                           at System.Runtime.Serialization.ObjectManager.DoNewlyRegisteredObjectFixups(ObjectHolder holder)
                           at System.Runtime.Serialization.ObjectManager.RegisterObject(Object obj, Int64 objectID, SerializationInfo info, Int64 idOfContainingObj, MemberInfo member, Int32[] arrayIndex)
                           at System.Runtime.Serialization.Formatters.Binary.ObjectReader.RegisterObject(Object obj, ParseRecord pr, ParseRecord objectPr, Boolean bIsString)
                           at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ParseObjectEnd(ParseRecord pr)
                           at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Parse(ParseRecord pr)
                           at System.Runtime.Serialization.Formatters.Binary.BinaryParser.Run()
                           at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(BinaryParser serParser, Boolean fCheck)
                           at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, Boolean check)
                           at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream)
                           at EpicGames.Core.BinaryFormatterUtils.Load[T](FileReference Location) in <engine>\Engine\Source\Programs\Shared\EpicGames.Core\BinaryFormatterUtils.cs:line 28
                           at UnrealBuildTool.HotReload.DeleteTemporaryFiles(FileReference HotReloadStateFile) in <engine>\Engine\Source\Programs\UnrealBuildTool\System\HotReload.cs:line 400

Unclear as to the root cause, but the solution is to do a clean build of your project (I.E delete the generated Intermediate/ folder from your project).

Since the error is related to the build failing to load some sort of hot reload state this fixes it.