{"record":{"id":"39ed02b5881b7e04","repo":"dotnet/wpf","slug":"sr-axwindowlesscontrol","errorCode":null,"errorMessage":"SR.AxWindowlessControl","messagePattern":"SR\\.AxWindowlessControl","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Controls/ActiveXSite.cs","lineNumber":182,"sourceCode":"        int UnsafeNativeMethods.IOleClientSite.ShowObject()\n        {\n            if (HostState >= ActiveXHelper.ActiveXState.InPlaceActive)\n            {\n                IntPtr hwnd;\n                if (NativeMethods.Succeeded(this.Host.ActiveXInPlaceObject.GetWindow(out hwnd)))\n                {\n                    if (this.Host.ControlHandle.Handle != hwnd)\n                    {\n                        if (hwnd != IntPtr.Zero)\n                        {\n                            this.Host.AttachWindow(hwnd);\n                            this.OnActiveXRectChange(this.Host.Bounds);\n                        }\n                    }\n                }\n                else if (this.Host.ActiveXInPlaceObject is UnsafeNativeMethods.IOleInPlaceObjectWindowless)\n                {\n                    throw new InvalidOperationException(SR.AxWindowlessControl);\n                }\n            }\n            return NativeMethods.S_OK;\n        }\n\n        int UnsafeNativeMethods.IOleClientSite.OnShowWindow(int fShow)\n        {\n            return NativeMethods.S_OK;\n        }\n\n        int UnsafeNativeMethods.IOleClientSite.RequestNewObjectLayout()\n        {\n            return NativeMethods.E_NOTIMPL;\n        }\n\n        #endregion IOleClientSite\n\n        //","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Controls/ActiveXSite.cs#L164-L200","documentation":"ActiveXSite.ShowObject checks whether the hosted ActiveX control implements IOleInPlaceObjectWindowless (a windowless control). Windowless controls cannot be shown in this hosting model, so the code throws InvalidOperationException(SR.AxWindowlessControl) instead of attempting the show.","triggerScenarios":"Hosting a windowless ActiveX control (implementing IOleInPlaceObjectWindowless) in a WPF WindowsFormsHost/ActiveX host and triggering in-place activation/ShowObject without a window.","commonSituations":"Embedding windowless controls (e.g. some video/scripting controls) that expect a windowless container; migrating a WinForms AxHost wrapper into WPF; controls requiring IViewObjectEx windowless support.","solutions":["Use a windowless-aware host (WinForms AxHost with proper windowless site support) instead of this WPF host","Host the control inside a WindowsFormsHost that provides windowed activation","Disable the control's windowless mode (control property/registry) so it activates windowed"],"exampleFix":"// before\n// windowless Ax control directly in WPF host -> throws\n// after\nvar host = new WindowsFormsHost();\nhost.Child = new AxMyWindowlessControlWrapper(); // WinForms wrapper provides windowed hosting","handlingStrategy":"validation","validationCode":"bool IsWindowless(IOleObject ctrl) => ctrl is UnsafeNativeMethods.IOleInPlaceObjectWindowless;","typeGuard":"bool SupportsWindowedActivation(object o) => o is not UnsafeNativeMethods.IOleInPlaceObjectWindowless;","tryCatchPattern":"try { site.ShowObject(); } catch (InvalidOperationException ex) when (ex.Message.Contains(\"windowless\")) { /* use windowed host */ }","preventionTips":["Check control type-library for IOleInPlaceObjectWindowless before hosting","Prefer windowed (AxHost/WindowsFormsHost) activation for windowless controls","Disable windowless mode on the control if supported"],"tags":["wpf","activex","windowless","interop"],"backgroundTag":"unsupported-operation","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"}