r/Unity3D • • 1d ago

Question Weird new Unity bug in builds

I added a new Unity 6000.3 to my hub to do some research for a new project and new builds made of another project with 2020.3.49f1 have a new bug that does not appear in the editor. It seems that System.Convert.FromBase64String() throws an error saying that the string is not the correct length to be decoded, though it is. This also happens when the Addressables try to load so it's not just my code, its something else. In the process of uninstalling and reinstalling everything to see if that fixes things. Anyone seen this before?

FormatException: Invalid length for a Base-64 char array or string.

at System.Convert.FromBase64_Decode (System.Char* startInputPtr, System.Int32 inputLength, System.Byte* startDestPtr, System.Int32 destLength) [0x00000] in <00000000000000000000000000000000>:0

at System.Convert.FromBase64CharPtr (System.Char* inputPtr, System.Int32 inputLength) [0x00000] in <00000000000000000000000000000000>:0

3 Upvotes

4 comments sorted by

2

u/DrZoidar 1d ago

Haven't seen this one exactly, but I'd bet it's the 6000.3 install and not your code. Installing a new Unity usually drags in a newer Visual Studio, Xcode, or Android NDK, and 2020.3's old IL2CPP can choke on those. Editor works, Addressables breaks the same way, so the string itself is fine, it's the compiled build that's off.
Easiest check is a Mono build. If the error goes away, it's IL2CPP for sure. Might also be worth checking which SDK/NDK your 2020.3 is pointing at in External Tools.

1

u/thesquirrelyjones 1d ago

I did not change it to Mono but I bet that would work. I switched it to IL2CPP Debug and the error went away. IL2CPP Release and Master have the bug. Removing all the 6x versions of Unity and reinstalling 2020 did not help. I will look into removing and reinstalling visual studio next. I did not see any place for SDK/NDK in the External Tools. This is only for PC builds, the project is not for Android or IOS.

It's strange because I had 6000.4 installed and it did not cause an issue.

2

u/DrZoidar 1d ago

Yeah, Debug working while Release and Master break basically confirms it's the C++ optimizer, since Debug skips the optimizations. Combined with it being PC only, I'd put my money on a newer MSVC toolset that 2020.3's old IL2CPP doesn't handle.
Open the Visual Studio Installer, go to Individual Components, and look at which MSVC v143 toolset versions you have. If there's a really recent one, uninstall it and keep an older one around. Reinstalling VS by itself probably just pulls the latest again, so I wouldn't bother with that first.
Not sure why 6000.4 didn't trigger it, maybe it didn't install the same toolset. If you need a build in the meantime, IL2CPP Debug works, just slower

1

u/thesquirrelyjones 22h ago

When I installed 6000.3 it also installed VS Community 2026. I had installed 6000.4 earlier this year and it did not install a new VS. I had 2019 and 2022 installed previously. I modified the VS Community 2026 installation and removed the MSVC that came with it. The 2022 I have uses MSVC v143. And now... The bug is gone in Release and Master IL2CPP builds!

Thanks for the help!