{"record":{"id":"0861e606749b6fd5","repo":"wailsapp/wails","slug":"cocreateinstance-failed-with-e-invalidarg","errorCode":null,"errorMessage":"CoCreateInstance failed with E_INVALIDARG","messagePattern":"CoCreateInstance failed with E_INVALIDARG","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/pkg/w32/ole32.go","lineNumber":64,"sourceCode":"func CoInitialize() {\n\tprocCoInitialize.Call(0)\n}\n\nfunc CoUninitialize() {\n\tprocCoUninitialize.Call()\n}\n\nfunc CoCreateInstance(clsid *syscall.GUID, dwClsContext uintptr, riid *syscall.GUID, ppv uintptr) HRESULT {\n\tret, _, _ := procCoCreateInstance.Call(\n\t\tuintptr(unsafe.Pointer(clsid)),\n\t\t0,\n\t\tuintptr(dwClsContext),\n\t\tuintptr(unsafe.Pointer(riid)),\n\t\tuintptr(ppv))\n\n\tswitch uint32(ret) {\n\tcase E_INVALIDARG:\n\t\tpanic(\"CoCreateInstance failed with E_INVALIDARG\")\n\tcase E_OUTOFMEMORY:\n\t\tpanic(\"CoCreateInstance failed with E_OUTOFMEMORY\")\n\tcase E_UNEXPECTED:\n\t\tpanic(\"CoCreateInstance failed with E_UNEXPECTED\")\n\t}\n\n\treturn HRESULT(ret)\n}\n\nfunc CreateStreamOnHGlobal(hGlobal HGLOBAL, fDeleteOnRelease bool) *IStream {\n\tstream := new(IStream)\n\tret, _, _ := procCreateStreamOnHGlobal.Call(\n\t\tuintptr(hGlobal),\n\t\tuintptr(BoolToBOOL(fDeleteOnRelease)),\n\t\tuintptr(unsafe.Pointer(&stream)))\n\n\tswitch uint32(ret) {\n\tcase E_INVALIDARG:","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/wailsapp/wails/blob/0e754b1b40ba9044c2a1460e23b7c3de20fc5cf3/v3/pkg/w32/ole32.go#L46-L82","documentation":"Error \"CoCreateInstance failed with E_INVALIDARG\" thrown in wailsapp/wails.","triggerScenarios":"Occurs when CoCreateInstance returns E_INVALIDARG, typically due to an invalid class/interface identifier or invalid creation flags.","commonSituations":"See trigger scenarios.","solutions":["Check all pointer arguments to CoCreateInstance: clsid and riid must be valid GUID pointers and ppv must be a valid output pointer; a null or malformed argument yields E_INVALIDARG.","Use a valid class context such as CLSCTX_INPROC_SERVER or CLSCTX_LOCAL_SERVER for dwClsContext."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0e754b1b40ba9044c2a1460e23b7c3de20fc5cf3","analyzedAt":"2026-08-15T14:17:36.034Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}