Delphi: got “EOleException with message ‘Microsoft MSXML is not installed'” in a console or test project?
Posted by jpluimers on 2021/03/31
Did you ever get this run-time error in a console or test project?
EOleException with message 'Microsoft MSXML is not installed'
It means that CoInitialize or CoInitializeEx needs to be called in the thread that uses MSXML.
Then an easy workaround is to:
- use the unit
System.Win.ComObjin any unit that (indirectly) usesXml.XMLDoc(for instance any unit using an XML Data Binding generated unit), - use the unit System.SysUtils as well (because it defines
TProcedureused below) - add this code in in your
initializationsection (which is what VCLTApplication.Initializedoes):
if InitProc <> nil then TProcedure(InitProc); // Calls CoInitialize for the main thread and prevents "EOleException with message 'Microsoft MSXML is not installed'"
The initialization section of System.Win.ComObj sets up InitProc to cals CoInitialize for the main thread, which usually suffices for these simple VCL projects, but not for most console or test projects.
Based on ideas I got after reading [WayBack] 为什么LoadXMLDocument在线程类中使用会报错?-CSDN论坛 (for which Google Translate actually does a goot job [Archive.is])
–jeroen






Leave a comment