HandyOrg/HandyControl · error · InvalidOperationException
The JumpList can't be applied until EndInit has been called.
Error message
The JumpList can't be applied until EndInit has been called.
What it means
JumpList.Apply() throws this InvalidOperationException when the JumpList is still in designer-initialization state (_initializing == true). WPF's ISupportInitialize pattern marks a JumpList as initializing between BeginInit and EndInit; applying the list before initialization completes would apply a partially constructed list.
Solutions
- Call EndInit() on the JumpList before calling Apply()
- Remove the explicit BeginInit() call if it is not needed
- Defer Apply() until after window/component initialization completes (e.g. Loaded event)
- Check the _initializing state / wrap Apply in try-catch InvalidOperationException to detect premature calls
Example fix
// before var jl = new JumpList(); jl.BeginInit(); jl.Apply(); // throws // after var jl = new JumpList(); jl.BeginInit(); jl.EndInit(); jl.Apply();
Defensive patterns
Strategy: validation
Validate before calling
bool isInitializing = typeof(JumpList).GetProperty("IsInitializing")?.GetValue(jumpList) as bool? ?? false;
if (isInitializing) jumpList.EndInit();
jumpList.Apply(); Type guard
static bool CanApply(JumpList jl) => jl != null; // apply only after BeginInit/EndInit pair completes
Try / catch
try { jumpList.Apply(); }
catch (InvalidOperationException ex) { Log.Warn("JumpList applied before EndInit", ex); } Prevention
- Always pair BeginInit with EndInit before Apply
- Apply JumpLists from the window's Loaded event, not during construction
- Prefer JumpList.SetJumpList + application-level wiring over manual lifecycle calls
When it happens
Trigger: Calling JumpList.Apply() (or SetJumpList + Apply) after BeginInit() but before EndInit(), or in XAML/data-binding scenarios where the framework is still initializing the object.
Common situations: Constructing a JumpList in code and calling Apply immediately after BeginInit; declaring a JumpList in XAML resource sections and invoking Apply from a handler that runs before the end-init pass; incorrect manual use of ISupportInitialize.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- Calls to BeginInit cannot be nested.
- Can't call EndInit without first calling BeginInit.
- The dialog is not a derived class of the FrameworkElement.
- Animation_NoTextChildren
- NotSupportedException
AI-assisted analysis of HandyOrg/HandyControl@2c0875ebd6 (2026-09-14).
Data as JSON: /api/errors/32012d22de4a609d.
Report an issue: GitHub.
Appendix: source
Thrown at src/Shared/Microsoft.Windows.Shell/JumpList.cs:167
string result;
HRESULT hrLeft = NativeMethods.GetCurrentProcessExplicitAppUserModelID(out result);
if (hrLeft == HRESULT.E_FAIL)
{
hrLeft = HRESULT.S_OK;
result = null;
}
hrLeft.ThrowIfFailed();
return result;
}
}
[SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "JumpList")]
[SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "EndInit")]
public void Apply()
{
if (this._initializing == true)
{
throw new InvalidOperationException("The JumpList can't be applied until EndInit has been called.");
}
this._initializing = new bool?(false);
this._ApplyList();
}
private void ApplyFromApplication()
{
if (this._initializing != true && !this._IsUnmodified)
{
this._initializing = new bool?(false);
}
if (this._application == Application.Current && this._initializing == false)
{
this._ApplyList();
}
}
[SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Standard.Verify.IsApartmentState(System.Threading.ApartmentState,System.String)")]View on GitHub (pinned to 2c0875ebd6)