{"record":{"id":"8b0eec1af96f9b30","repo":"iOfficeAI/OfficeCLI","slug":"word-not-authentic-name","errorCode":null,"errorMessage":"word_not_authentic: {name}","messagePattern":"word_not_authentic: (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/officecli/Core/WordPdfBackend.cs","lineNumber":461,"sourceCode":"                int srcStride = p.w * 4;\n                for (int row = 0; row < p.h; row++)\n                    Array.Copy(p.pixels, row * srcStride, target, (y0 + row) * targetStride + x0 * 4, srcStride);\n            }\n            return EncodeBgraToPng(factory, target, W, H);\n        }\n        finally { Marshal.Release(factory); }\n    }\n\n    static string DocxToPdf(string docx)\n    {\n        var pdf = Path.Combine(Path.GetTempPath(), $\"_w_{Guid.NewGuid():N}.pdf\");\n        var clsid = G_Word; var iid = G_IDispatch;\n        CoCreateInstance(ref clsid, IntPtr.Zero, 4, ref iid, out var word);\n        try\n        {\n            var name = (string?)DispGet(word, \"Name\") ?? \"\";\n            if (!name.Contains(\"Microsoft Word\", StringComparison.OrdinalIgnoreCase))\n                throw new InvalidOperationException(\"word_not_authentic: \" + name);\n\n            DispSet(word, \"Visible\", false);\n            DispSet(word, \"DisplayAlerts\", 0);\n            try { DispSet(word, \"AutomationSecurity\", 3); } catch { }\n\n            var docs = (IntPtr)DispGet(word, \"Documents\")!;\n            try\n            {\n                var doc = (IntPtr)DispMethod(docs, \"Open\", docx, MISSING, true, false)!;\n                try { DispMethod(doc, \"SaveAs2\", pdf, 17); }\n                finally { try { DispMethod(doc, \"Close\", false); } catch { } Marshal.Release(doc); }\n            }\n            finally { Marshal.Release(docs); }\n        }\n        finally\n        {\n            try { DispMethod(word, \"Quit\"); } catch { }\n            Marshal.Release(word);","sourceCodeStart":443,"sourceCodeEnd":479,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Core/WordPdfBackend.cs#L443-L479","documentation":"Thrown by DocxToPdf after CoCreateInstance instantiates CLSID {000209FF-0000-0000-C000-000000000046} (Word.Application) and queries its Name property. If the name does not contain 'Microsoft Word' (case-insensitive), the backend refuses to proceed, because a different application or a non-Word COM server registered under that CLSID would silently produce garbage or hang. This is a security/authenticity guard: it prevents the PDF backend from driving an unexpected or spoofed COM server that happens to occupy Word's class ID.","triggerScenarios":"The CLSID {000209FF-...} is registered but resolves to something other than Microsoft Word — e.g. an Outlook MAPI or Office runtime stub on machines with only a partial Office install, a third-party application that hijacked the CLSID, a Wine/Corosiva-CrossOver environment where the COM server reports a different Name, or a registry corruption where Word is partially uninstalled but the CLSID entry remains.","commonSituations":"Server with Office Online Server or Office runtime redistributable but no desktop Word; a machine with only Microsoft 365 click-to-run streaming stub where Word is not fully downloaded yet; WINE/CrossOver where the COM bridge reports a Wine-specific name; a damaged Office install after a failed update.","solutions":["Run 'winword.exe' manually to confirm Word launches and reports itself as 'Microsoft Word' in its title bar.","Repair the Office installation: Settings > Apps > Microsoft 365/Office > Modify > Online Repair.","If the Name property returns a localized or version-specific string (e.g. 'Microsoft Word 2016'), the Contains check already handles that — if it still fails, inspect the exact Name value returned and report it.","On a server, install Word via a volume-license Office build rather than click-to-run, which is known to leave registration stubs."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Check that Word reports itself correctly before relying on the backend\n// This mirrors the internal check; if it fails, PDF conversion is unavailable\nvar clsid = new Guid(\"000209FF-0000-0000-C000-000000000046\");\nvar iid = new Guid(\"00020400-0000-0000-C000-000000000046\");\ntry\n{\n    WordPdfBackend.CoCreateInstance(ref clsid, IntPtr.Zero, 4, ref iid, out var word);\n    try\n    {\n        var name = (string)WordPdfBackend.DispGet(word, \"Name\");\n        if (!name.Contains(\"Microsoft Word\", StringComparison.OrdinalIgnoreCase))\n            throw new PlatformNotSupportedException($\"Word authenticity check failed: {name}\");\n    }\n    finally { Marshal.Release(word); }\n}\ncatch { /* Word not available or not authentic */ }","typeGuard":null,"tryCatchPattern":"try\n{\n    var pdf = WordPdfBackend.DocxToPdf(docxPath);\n}\ncatch (InvalidOperationException ex) when (ex.Message.StartsWith(\"word_not_authentic\"))\n{\n    // The COM server under Word's CLSID is not genuine Microsoft Word\n    logger.LogError(\"Word authenticity check failed: {Detail}\", ex.Message);\n    throw new PlatformNotSupportedException(\n        \"PDF conversion requires genuine Microsoft Word to be installed.\");\n}","preventionTips":["Install the full desktop Microsoft Word application, not just Office runtimes or viewers.","On servers, use a volume-license Office build; avoid click-to-run stubs that may not fully register.","If using Wine/CrossOver, verify the COM bridge reports the expected Name property.","Run a Word repair (Online Repair via Settings > Apps) if the install is partially damaged."],"tags":["com-interop","word-automation","pdf-conversion","windows-only","authenticity-check"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}