String conversion errors from RuntimeAssembly.GetCodeBase with Japanese locale and/or paths
tracked
bd_
I've been getting reports from multiple Japanese users that they are getting the following stacktrace, breaking the build window in the Avatar SDK:
ExecutionEngineException: String conversion error: Illegal byte sequence encounted in the input.
System.Reflection.RuntimeAssembly.GetCodeBase (System.Reflection.Assembly a, System.Boolean escaped) (at <27124aa0e30a41659b903b822b959bc7>:0)
System.Reflection.RuntimeAssembly.get_CodeBase () (at <27124aa0e30a41659b903b822b959bc7>:0)
System.Reflection.AssemblyName.Create (System.Reflection.Assembly assembly, System.Boolean fillCodebase) (at <27124aa0e30a41659b903b822b959bc7>:0)
System.Reflection.RuntimeAssembly.GetName (System.Boolean copiedName) (at <27124aa0e30a41659b903b822b959bc7>:0)
System.Reflection.Assembly.GetName () (at <27124aa0e30a41659b903b822b959bc7>:0)
VRC.Tools.get_HasTypeVRCApplication () (at <de2b87b788984fa39f4913eb18084fa8>:0)
VRC.Tools.get_isClient () (at <de2b87b788984fa39f4913eb18084fa8>:0)
VRC.Core.API.PopulateHTTPRequestHeaders (BestHTTP.HTTPRequest request) (at <de2b87b788984fa39f4913eb18084fa8>:0)
VRC.Core.API.SendRequestInternal (System.String endpoint, BestHTTP.HTTPMethods method, VRC.Core.ApiContainer responseContainer, System.Collections.Generic.IReadOnlyDictionary`2[TKey,TValue] requestParams, System.Boolean authenticationRequired, System.Boolean disableCache, System.Single cacheLifetime, System.Int32 retryCount, VRC.Core.API+CredentialsBundle credentials, BestHTTP.Forms.HTTPFormBase formData, System.Boolean disableLog, VRC.Core.UpdateDelegator+JobPriority priority) (at <de2b87b788984fa39f4913eb18084fa8>:0)
VRC.Core.API+<>c__DisplayClass49_0.<SendRequest>g__PerformRequest|0 () (at <de2b87b788984fa39f4913eb18084fa8>:0)
VRC.Core.API.SendRequest (System.String endpoint, BestHTTP.HTTPMethods method, VRC.Core.ApiContainer responseContainer, System.Collections.Generic.IReadOnlyDictionary`2[TKey,TValue] requestParams, System.Boolean authenticationRequired, System.Boolean disableCache, System.Single cacheLifetime, System.Int32 retryCount, VRC.Core.API+CredentialsBundle credentials, BestHTTP.Forms.HTTPFormBase formData, System.Boolean disableLog, VRC.Core.UpdateDelegator+JobPriority priority) (at <de2b87b788984fa39f4913eb18084fa8>:0)
VRC.Core.RemoteConfig.FetchConfig (System.Action onFetched, System.Action onError) (at <de2b87b788984fa39f4913eb18084fa8>:0)
VRC.Core.BaseConfig.Init (System.Action onInit, System.Action onError, System.Boolean reload) (at <de2b87b788984fa39f4913eb18084fa8>:0)
VRCSdkControlPanel.ShowControlPanel () (at ./Packages/com.vrchat.base/Editor/VRCSDK/Dependencies/VRChat/ControlPanel/VRCSdkControlPanel.cs:25)
Some folks claim that this starts when they install Modular Avatar, and persists after removing it. It may be related to https://github.com/mono/mono/issues/20968 - calling Assembly.GetName appears to be unsafe on the version of mono in Unity 2022.3.22f1.
This bug appears to be very sensitive to load order. In particular, it will occur when:
- Your PC nonunicode locale is Japanese, and there is Japanese text in the project path
- An assembly listed before Assembly-CSharpin theAppDomain.CurrentDomain.GetAssemblies()list is one which throws an exception fromassembly.Name. This can be any assembly that is dynamically constructed (notably, HarmonySharedState assemblies and some "external tools" bindings, such as the Rider bindings, will trigger this)
I would suggest adding exception handling to this isClient check, and skipping assemblies that throw exceptions from GetName. Or, check for the presence of VRCApplication using
Assembly.GetType
first, and then check for whether this is Assembly-CSharp
only if you find that class.Log In
StormRel
tracked
bd_
This appears to be triggered by Modular Avatar as Modular Avatar initializes Harmony, which creates one of these problem assemblies. However, in a blank worlds project, there are multiple assemblies which throw on
GetName
, and therefore will break depending on load order (notably, UdonSharpRoslynCompileAssembly0
and UdonSharpRoslynCompileAssembly1
, as well as JetBrains.Rider.Unity.Editor.Plugin.Net46.Repacked
if Rider is selected as an external editor).bd_
In the meantime, I intend to work around this issue for my users by Harmony patching HasTypeVRCApplication to always return false. Hopefully you're not using Modular Avatar in the VRC Client itself!