简体   繁体   中英

How to: Programmatically detect if MSXML parser (version 3+) is installed or not

Can anyone help me out, how to detect if MSXML parser is installed on a machine or not. I looked for a registry entry,but unable to get one. I am writing a VB.NET application. Thanks in advance :)

I would check if these files exists and check the version.

Or I would use this

Or maybe there is a better way?

If possible, target MSXML 3.0. It's included in all Windows operating systems starting with Win2k SP4 , so there's usually no need to check for it's presence.

Anyway, if you are using VB.NET, consider using the System.Xml namespace instead. It is part of the .net framework, which is needed by your VB.NET application anyway.

One way you can do it is to create an instance of one of the MSXML objects in your code. eg

Dim t As Type
Dim o As Object

' If this code causes an exception the object doesn't exist t = Type.GetTypeFromProgID("MSXML2.DOMDocument") o = Activator.CreateInstance(t); System.Runtime.InteropServices.Marshal.ReleaseComObject(o)

I apologize if my vb.net code is bad :)

需要注意的一件事是.NET应用程序不支持使用MSXML,因为MSXML内的GC与.Net框架不兼容。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM