Hello,
I have created simple COM service in .NET. COM is accessed from another
not NET application by late binding call.
And the problem:
If I call NetComClass.Hello from another .NET code, all works fine. But
when calling from COM, the program hangs at line nodeList =
root.SelectNodes("/bookstore/book"). CPU is utilized 100%. Briefly:
XmlDocument.SelectNodes call hangs EVERY TIME when selected nodes count
is greater than 0. I have attached debugger to calling process, I have
spend many hour on this problem, but without any result.
This is a test program to simplify the problem with SelectNode from more
complex part of application. The behaviour is the same.
Does anybody know, where the problem is?
***** script *****
WScript.StdOut.Write("Press Enter")
WScript.StdIn.Read(0)
strTemp = WScript.StdIn.ReadLine()
Set Obj = CreateObject("Anete.TestCom.NetComClass")
Obj.Hello()
** test dll ***
Imports System.Diagnostics
Imports System.Xml
Imports System
Namespace Anete.TestCOM
<ComClass(NetComClass.ClassId, NetComClass.InterfaceId,
NetComClass.EventsId)_
Public Class NetComClass
#Region "COM GUIDs"
' These GUIDs provide the COM identity for this class
' and its COM interfaces. If you change them, existing
' clients will no longer be able to access the class.
Public Const ClassId As String =
"a1fe8f7b-aee7-4db7-9e49-7a4a10c6a03d"
Public Const InterfaceId As String =
"0a8dc583-7f23-4523-9f05-70e35c4dc2de"
Public Const EventsId As String =
"93e01224-a3ad-418c-8fba-1b781914f289"
#End Region
' A creatable COM class must have a Public Sub New()
' with no parameters, otherwise, the class will not be
' registered in the COM registry and cannot be created
' via CreateObject.
Public Sub New()
MyBase.New()
Trace.Write("New")
End Sub
Public Sub Hello(ByVal baseDir As String)
' Create the XmlDocument.
Dim doc As XmlDocument = New XmlDocument()
doc.Load(baseDir + "\" + "booksort.xml")
Dim book As XmlNode
Dim nodeList As XmlNodeList
Dim root As XmlNode = doc.DocumentElement
' on this line COM hangs
nodeList = root.SelectNodes("/bookstore/book")
End Sub
End Class
End Namespace
<?xml version='1.0'?>
<bookstore>
<book genre="novel" style="hardcover">
<title>The Handmaid's Tale</title>
<author>
<first-name>Margaret</first-name>
<last-name>Atwood</last-name>
</author>
<price>19.95</price>
</book>
<book genre="novel" style="other">
<title>The Poisonwood Bible</title>
<author>
<first-name>Barbara</first-name>
<last-name>Kingsolver</last-name>
</author>
<price>11.99</price>
</book>
</bookstore>
Karel
--
---------
Environment: VB.NET, VS2005 Pro, XP Pro/P4 3GHz, 2GB RAM
__________________________________________________ _
Karel Kral, developer
ANETE, s.r.o.
__________________________________________________ _