Cannot sync with any CustomFarmingRedux machines running
dmstocking opened this issue ยท 0 comments
Ok so this is a weird one and I am pretty sure it probably also happens when reading but I don't know for sure because I couldn't find a good solution.
So the problem is to just get any CustomFarmingRedux.CustomMachine that can hold a CustomFarmingRedux.Object. In my case, this was using the industrialization lite mod. I had a "Alternator Furnace" processing a "Pulverized Iridium". Now when a new player goes to join the game, this causes the PySync.writeFull to try and write the XML for that object. Now this particular one acts like a "Chest" the XML serializer is only setup to serialize the type of the element being synced and not any sub-elements. This causes it to hit the "CustomFarmRedux.CustomObject" and produce an exception similar to this one. (I have been playing with this code in my spare time so sorry if the line numbers are off. If they are it is because I was trying to add logging to figure out what was going on.)
[game] An error occured in the base update loop: System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException: The type CustomFarmingRedux.CustomObject was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically.
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterChest.Write16_Item(String n, String ns, Item o, Boolean isNullable, Boolean needType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterChest.Write56_Chest(String n, String ns, Chest o, Boolean isNullable, Boolean needType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterChest.Write57_Chest(Object o)
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
at System.Xml.Serialization.XmlSerializer.Serialize(TextWriter textWriter, Object o, XmlSerializerNamespaces namespaces)
at PyTK.CustomElementHandler.PySync.WriteFull(BinaryWriter writer) in C:\Users\Courtney\Documents\Stardew\Modding\Stardew-Valley-Mods-master-Routine\Stardew-Valley-Mods-master\PyTK\CustomElementHandler\PySync.cs:line 97
at Netcode.NetFields.WriteFull(BinaryWriter writer) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Netcode\NetFields.cs:line 117
at Netcode.NetExtendableRef`2.WriteValueFull(BinaryWriter writer) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Netcode\NetRef.cs:line 302
at Netcode.NetRefBase`2.WriteFull(BinaryWriter writer) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Netcode\NetRef.cs:line 236
at Netcode.NetDictionary`5.WriteFieldFull(BinaryWriter writer, TField field) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Netcode\NetDictionary.cs:line 357
at Netcode.NetDictionary`5.WriteFull(BinaryWriter writer) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Netcode\NetDictionary.cs:line 575
at Netcode.NetFields.WriteFull(BinaryWriter writer) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Netcode\NetFields.cs:line 117
at Netcode.NetExtendableRef`2.WriteValueFull(BinaryWriter writer) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Netcode\NetRef.cs:line 302
at Netcode.NetRefBase`2.WriteFull(BinaryWriter writer) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Netcode\NetRef.cs:line 236
at Netcode.NetFields.WriteFull(BinaryWriter writer) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Netcode\NetFields.cs:line 117
at Netcode.NetExtendableRef`2.WriteValueFull(BinaryWriter writer) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Netcode\NetRef.cs:line 302
at Netcode.NetRefBase`2.WriteFull(BinaryWriter writer) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Netcode\NetRef.cs:line 236
at Netcode.NetDictionary`5.WriteFieldFull(BinaryWriter writer, TField field) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Netcode\NetDictionary.cs:line 357
at Netcode.NetDictionary`5.WriteFull(BinaryWriter writer) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Netcode\NetDictionary.cs:line 580
at Netcode.NetCollection`1.WriteFull(BinaryWriter writer) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Netcode\NetCollection.cs:line 239
at Netcode.NetFields.WriteFull(BinaryWriter writer) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Netcode\NetFields.cs:line 117
at Netcode.NetExtendableRef`2.WriteValueFull(BinaryWriter writer) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Netcode\NetRef.cs:line 302
at Netcode.NetRefBase`2.WriteFull(BinaryWriter writer) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Netcode\NetRef.cs:line 236
at Netcode.NetRoot`1.CreateConnectionPacket(BinaryWriter writer, Nullable`1 connection) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Netcode\NetRoot.cs:line 113
at StardewValley.Multiplayer.writeObjectFullBytes[T](NetRoot`1 root, Nullable`1 peer) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Farmer\Network\Multiplayer.cs:line 629
at StardewValley.Network.GameServer.sendLocation(Int64 peer, GameLocation location) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Farmer\Network\GameServer.cs:line 534
at sendServerIntroduction_Patch3(Object peer, Int64 )
at StardewValley.Network.GameServer.<>c__DisplayClass39_0.<checkFarmhandRequest>b__0() in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Farmer\Network\GameServer.cs:line 476
at StardewValley.Network.GameServer.whenGameAvailable(Action action, Func`1 customAvailabilityCheck) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Farmer\Network\GameServer.cs:line 352
at StardewValley.Network.GameServer.checkFarmhandRequest(String userID, String connectionID, NetFarmerRoot farmer, Action`1 sendMessage, Action approve) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Farmer\Network\GameServer.cs:line 425
at StardewModdingAPI.Framework.Networking.SGalaxyNetServer.<>c__DisplayClass3_0.<onReceiveMessage>b__1() in C:\source\_Stardew\SMAPI\src\SMAPI\Framework\Networking\SGalaxyNetServer.cs:line 61
at StardewModdingAPI.Framework.SMultiplayer.OnServerProcessingMessage(IncomingMessage message, Action`1 sendMessage, Action resume) in C:\source\_Stardew\SMAPI\src\SMAPI\Framework\SMultiplayer.cs:line 234
at StardewModdingAPI.Framework.Networking.SGalaxyNetServer.onReceiveMessage(GalaxyID peer, Stream messageStream) in C:\source\_Stardew\SMAPI\src\SMAPI\Framework\Networking\SGalaxyNetServer.cs:line 53
at StardewValley.SDKs.GalaxySocket.Receive(Action`1 onConnection, Action`2 onMessage, Action`1 onDisconnect, Action`1 onError) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Farmer\SDKs\GalaxySocket.cs:line 475
at StardewValley.SDKs.GalaxyNetServer.receiveMessages() in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Farmer\SDKs\GalaxyNetServer.cs:line 179
at StardewValley.Network.GameServer.receiveMessages() in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Farmer\Network\GameServer.cs:line 161
at StardewValley.Multiplayer.UpdateEarly() in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Farmer\Network\Multiplayer.cs:line 1497
at StardewValley.Game1._update(GameTime gameTime) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Farmer\Game1.cs:line 3066
at StardewValley.Game1.Update(GameTime gameTime) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Farmer\Game1.cs:line 2900
at Update_Patch1(Object gameTime, GameTime )
I honestly cannot think of a way to fix this issue besides trying to implement IXmlSerializable everywhere. I am not experience with how Stardew/SMAPI/PyTK works so maybe there is an easy way?