Click here to Skip to main content
15,798,508 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a com component, which i have registered and added as reference in my project. While trying to access its method I am getting the above error. Need your help.

Below is the code snippet

Dim testResult As Object = Nothing
Dim oxmldom As Object
Dim sXML As String
sXML = ""
testResult = CreateObject("ComReferenceDLL.iInterface1")
oxmldom = CreateObject("MSXML2.DOMDocument")
oxmldom = testResult.SampleMethod(sXML)

Here ComReferenceDLL is the COM component.
Updated 19-May-13 20:28pm
Sergey Alexandrovich Kryukov 20-May-13 1:40am    
Why? why?!

1 solution

Of course you cannot. Who told you these type are related somehow, forget about its assignment compatibility.

You should not mix old-not-so-good COM with .NET FCL classes, which already provide you will all you need to reading, parsing and generating XML. This is my short overview of them:
  1. Use System.Xml.XmlDocument class. It implements DOM interface; this way is the easiest and good enough if the size if the document is not too big.
  2. Use the class System.Xml.XmlTextReader; this is the fastest way of reading, especially is you need to skip some data.
  3. Use the class System.Xml.Linq.XDocument; this is the most adequate way similar to that of XmlDocument, supporting LINQ to XML Programming.

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900