dotnet/wpf · error · TargetInvocationException
SR.Format(SR.AXNohWnd, GetType().Name)
Error message
SR.Format(SR.AXNohWnd, GetType().Name)
What it means
During ActiveXHost.TransitionFromRunningToInPlaceActive, if the in-place activation of the ActiveX control fails and the control produces no HWND, non-critical failures are rethrown wrapped in a TargetInvocationException with the AXNohWnd message (including the control type name). It signals the control reached a state where WPF cannot host it because no window handle was created.
Solutions
- Inspect the InnerException of the TargetInvocationException for the real failure cause from the control.
- Re-register the ActiveX control (regsvr32) and verify its COM registration and licensing.
- Ensure the control is created on an STA UI thread in an interactive session; avoid hosting in Windows services.
- Replace or update the control if it does not support in-place activation with an HWND.
Example fix
// before
try { host.Activate(); }
catch (Exception ex) { Log(ex.Message); }
// after
try { host.Activate(); }
catch (TargetInvocationException tie) {
Log($"ActiveX failed: {tie.InnerException}"); // real cause
} Defensive patterns
Strategy: try-catch
Validate before calling
// Verify the control is registered and activatable before hosting: // Type.GetTypeFromCLSID(clsid) + Activator.CreateInstance smoke test on an STA thread
Try / catch
try
{
host.TransitionUpTo(ActiveXHelper.ActiveXState.InPlaceActive);
}
catch (TargetInvocationException ex)
{
var cause = ex.InnerException;
Log($"ActiveX {host.GetType().Name} failed to activate: {cause}");
} Prevention
- Always inspect InnerException of TargetInvocationException for the root cause.
- Verify COM registration (regsvr32) before deploying hosts of ActiveX controls.
- Host controls only on interactive STA UI threads, never in services/headless sessions.
When it happens
Trigger: Calling TransitionUpTo to activate an ActiveX control where the underlying OLE in-place activation fails (returns a failure HRESULT or leaves hWnd zero) with a non-critical exception cause.
Common situations: Broken or unregistered ActiveX controls, controls that refuse in-place activation, missing COM registration, or controls failing under restricted environments (services, non-interactive sessions).
Related errors
- SR.AxWindowlessControl
- SR.HwndTarget_InvalidWindowHandle
- SR.HwndTarget_InvalidWindowProcess
- SR.HwndTarget_InvalidWindowThread
- SR.HwndTarget_WindowAlreadyHasContent
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/b3231e770d55fe6d.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/ActiveXHost.cs:662
private void TransitionFromRunningToInPlaceActive()
{
Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.Running, "Wrong start state to transition from");
if (this.ActiveXState == ActiveXHelper.ActiveXState.Running)
{
try
{
DoVerb(NativeMethods.OLEIVERB_INPLACEACTIVATE);
}
catch (Exception e)
{
if(CriticalExceptions.IsCriticalException(e))
{
throw;
}
else
{
throw new TargetInvocationException(SR.Format(SR.AXNohWnd, GetType().Name), e);
}
}
//
// We are now InPlaceActive!
this.ActiveXState = ActiveXHelper.ActiveXState.InPlaceActive;
}
}
private void TransitionFromInPlaceActiveToRunning()
{
Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.InPlaceActive, "Wrong start state to transition from");
if (this.ActiveXState == ActiveXHelper.ActiveXState.InPlaceActive)
{
//
// InPlaceDeactivate.
_axOleInPlaceObject.InPlaceDeactivate();
View on GitHub (pinned to 81131a70a4)