So I’m testing my game from a build now instead of just the editor. Everything works fine in the editor, but when I build it I get an error when I try to read an XML file (don’t know if it does it with write as well, I haven’t tested that).

In the build it says

ArgumentException: Encoding name 'Windows-1252' not supported
Parameter name: name

It points me to this section of my code

public static invGamePiece LoadXML(string fileName){
		using (var stream = new FileStream(fileName, FileMode.Open)){
			var serializer = new XmlSerializer(typeof(invGamePiece));
			return (invGamePiece) serializer.Deserialize(stream);
		}
	}

specifically to this line

return (invGamePiece) serializer.Deserialize(stream);

How can I fix this to work in build?

Try encoding your XML file in UTF-8 without BOM. You can use Notepad++ for this, for example.

I found the answer: CodePage 1252 not supported - works in editor but not in standalone player - Unity Answers

It’s annoying to have to copy dlls, but it makes it work.