{"record":{"id":"b3231e770d55fe6d","repo":"dotnet/wpf","slug":"sr-format-sr-axnohwnd-gettype-name","errorCode":null,"errorMessage":"SR.Format(SR.AXNohWnd, GetType().Name)","messagePattern":"SR\\.Format\\(SR\\.AXNohWnd, GetType\\(\\)\\.Name\\)","errorType":"exception","errorClass":"TargetInvocationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/ActiveXHost.cs","lineNumber":662,"sourceCode":"\n        private void TransitionFromRunningToInPlaceActive()\n        {\n            Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.Running, \"Wrong start state to transition from\");\n            if (this.ActiveXState == ActiveXHelper.ActiveXState.Running)\n            {\n                try\n                {\n                    DoVerb(NativeMethods.OLEIVERB_INPLACEACTIVATE);\n                }\n                catch (Exception e)\n                {\n                    if(CriticalExceptions.IsCriticalException(e))\n                    {\n                        throw;\n                    }\n                    else\n                    {\n                        throw new TargetInvocationException(SR.Format(SR.AXNohWnd, GetType().Name), e);\n                    }\n                }\n\n                //\n                // We are now InPlaceActive!\n                this.ActiveXState = ActiveXHelper.ActiveXState.InPlaceActive;\n            }\n        }\n\n        private void TransitionFromInPlaceActiveToRunning()\n        {\n            Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.InPlaceActive, \"Wrong start state to transition from\");\n            if (this.ActiveXState == ActiveXHelper.ActiveXState.InPlaceActive)\n            {\n                //\n                // InPlaceDeactivate.\n                _axOleInPlaceObject.InPlaceDeactivate();\n","sourceCodeStart":644,"sourceCodeEnd":680,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/ActiveXHost.cs#L644-L680","documentation":"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.","triggerScenarios":"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.","commonSituations":"Broken or unregistered ActiveX controls, controls that refuse in-place activation, missing COM registration, or controls failing under restricted environments (services, non-interactive sessions).","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."],"exampleFix":"// before\ntry { host.Activate(); }\ncatch (Exception ex) { Log(ex.Message); }\n// after\ntry { host.Activate(); }\ncatch (TargetInvocationException tie) {\n    Log($\"ActiveX failed: {tie.InnerException}\"); // real cause\n}","handlingStrategy":"try-catch","validationCode":"// Verify the control is registered and activatable before hosting:\n// Type.GetTypeFromCLSID(clsid) + Activator.CreateInstance smoke test on an STA thread","typeGuard":null,"tryCatchPattern":"try\n{\n    host.TransitionUpTo(ActiveXHelper.ActiveXState.InPlaceActive);\n}\ncatch (TargetInvocationException ex)\n{\n    var cause = ex.InnerException;\n    Log($\"ActiveX {host.GetType().Name} failed to activate: {cause}\");\n}","preventionTips":["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."],"tags":["wpf","activex","interop","hwnd"],"backgroundTag":"com-activation-failed","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}