Unity-Technologies/UnityCsReference · error · Exception

{0}, the raw string was {1}

Error message

{0}, the raw string was {1}

What it means

The packageVersion getter wraps any exception from constructing System.Version(ValidatePackageVersion(packageVersionRaw)) and rethrows it as a new System.Exception formatted "{inner message}, the raw string was <packageVersionRaw>". In normal operation ValidatePackageVersion normalizes the value to either the regex-matched d.d.d.d form or the fallback "1.0.0.0", both valid for System.Version, so this throw is effectively unreachable through the public getter unless packageVersionRaw is corrupted at the native/storage layer or a future change breaks the contract. It exists to surface the offending raw string when version parsing fails.

Source

Thrown at Editor/Mono/PlayerSettingsWSA.cs:91

            public static void SetVisualAssetsImage(string image, WSAImageType type, WSAImageScale scale)
            {
                ValidateWSAImageType(type);
                ValidateWSAImageScale(scale);
                SetWSAImage(image, type, scale);
            }

            public static System.Version packageVersion
            {
                get
                {
                    try
                    {
                        return new System.Version(ValidatePackageVersion(packageVersionRaw));
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(string.Format("{0}, the raw string was {1}", ex.Message, packageVersionRaw));
                    }
                }
                set { packageVersionRaw = value.ToString(); }
            }


            public static System.DateTime? certificateNotAfter
            {
                get
                {
                    long value = certificateNotAfterRaw;
                    if (value != 0)
                        return System.DateTime.FromFileTime(value);
                    else
                        return null;
                }
            }

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. Wrap reads of packageVersion in try/catch (Exception) and report the raw value from your own log, since the engine already attaches it.
  2. Reset the WSA package version in Player Settings UI to a clean major.minor.build.revision value.
  3. If persistently reproducible, inspect packageVersionRaw source / ProjectSettings asset for corruption and re-save it.
  4. Report a Unity bug if a valid 4-part numeric version still triggers the throw (would indicate an engine regression).

Example fix

// before
System.Version v = PlayerSettings.WSA.packageVersion;

// after — defensive read with explicit fallback policy
System.Version v;
try
{
    v = PlayerSettings.WSA.packageVersion;
}
catch (Exception ex)
{
    UnityEngine.Debug.LogError("Failed to read WSA packageVersion: " + ex.Message);
    v = new System.Version(1, 0, 0, 0);
}
Defensive patterns

Strategy: try-catch

Validate before calling

// packageVersion normalizes internally, so pre-validation is limited to the raw field shape.
static bool LooksLikeValidPackageVersion(string raw)
    => !string.IsNullOrEmpty(raw) &&
       System.Text.RegularExpressions.Regex.IsMatch(raw, @"^\d+\.\d+\.\d+\.\d+$");

Try / catch

System.Version v;
try
{
    v = PlayerSettings.WSA.packageVersion;
}
catch (System.Exception ex)
{
    // The engine already appends ", the raw string was <value>" to the message.
    UnityEngine.Debug.LogError("WSA packageVersion read failed: " + ex.Message);
    v = new System.Version(1, 0, 0, 0);
}

Prevention

When it happens

Trigger: The native backing field packageVersionRaw holding a value that defeats ValidatePackageVersion's normalization (corrupted PlayerSettings serialization, direct native mutation, or a non-string object). Effectively cannot fire from managed-only code paths because both ValidatePackageVersion outputs parse cleanly.

Common situations: Corrupted Library/ProjectSettings serialization after a crash, hand-edited or merge-conflicted ProjectSettings asset affecting the WSA package version field, or a bug in a native editor extension writing an invalid value. Exceedingly rare in normal use.

Related errors


AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13). Data as JSON: /api/errors/457f4bcd907ac7ce. Report an issue: GitHub.