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
- Wrap reads of packageVersion in try/catch (Exception) and report the raw value from your own log, since the engine already attaches it.
- Reset the WSA package version in Player Settings UI to a clean major.minor.build.revision value.
- If persistently reproducible, inspect packageVersionRaw source / ProjectSettings asset for corruption and re-save it.
- 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
- Always read packageVersion inside try/catch; the getter can rethrow a wrapped exception.
- Set the WSA package version through the Player Settings UI or a clean 4-part numeric string.
- Treat Library/ProjectSettings corruption as a trigger; re-save the asset if the throw recurs.
- File a Unity bug if a valid major.minor.build.revision value still causes the throw.
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
- Unknown WSA image type: {type}
- Unknown image scale: {scale}
- PlayerSettings.storeTileLogo80 is deprecated. Use GetVisualA
- PlayerSettings.storeTileLogo80 is deprecated. Use SetVisualA
- PlayerSettings.storeTileLogo is deprecated. Use GetVisualAss
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/457f4bcd907ac7ce.
Report an issue: GitHub.