I've developed a com object which reads a xml file and stored
a connection string in a shared property bag. It works fine on
a IIS 4.0 server. On a windows 2000 server it goes south. It will
read the xml file and return use the connection string on the first
call, all subsequent calls it attempts to access the shared property bag.
When it attempts to do this, the com object goes south on a win 2000
server. It works flawlessly on a IIS 4.0 server.
The following is the code I'm using...any help would be grately appreciated
Jim
Private Sub ObjectControl_Activate()
Set mobjContext = GetObjectContext
Dim strConnectString
Dim spmMgr As SharedPropertyGroupManager
Dim spmGroup As SharedPropertyGroup
Dim spmProp As SharedProperty
Dim bGroupExists As Boolean
Dim bPropExists As Boolean
Set spmMgr = CreateObject _
("MTxSpm.SharedPropertyGroupManager.1")
Set spmGroup = spmMgr.CreatePropertyGroup _
(Trim("spGroup"), LockMethod, Process, bGroupExists)
Set spmProp = spmGroup.CreateProperty _
(Trim("spProperty"), bPropExists)
If bPropExists = False Then
spConnString = GetXMLDBCONN()
SetXMLDBCONN (spConnString)
Else
spConnString = spmProp.Value
End If
mobjContext.SetComplete
End Sub
Private Sub ObjectControl_Deactivate()
Set mobjContext = Nothing
End Sub
Private Function ObjectControl_CanBePooled() As Boolean
'Uncomment one choic:
ObjectControl_CanBePooled = True 'It's OK to recycle the object
'ObjectControl_CanBePooled = False 'It's not OK to recycle the object
End Function
Public Function GetXMLDBCONN() As String
Dim xDoc As New DOMDocument
Dim iElement
Dim nextNode
Dim i
Dim child
Dim vConnString
xDoc.async = False
xDoc.Load ("c:\xml\dbconn.xml")
Set iElement = xDoc.documentElement
For i = 0 To iElement.childNodes.Item(0).childNodes.length - 1
If i = 0 Then
vConnString = Chr(34)
End If
vConnString = vConnString +
iElement.childNodes.Item(0).childNodes.Item(i).nodeName + "=" _
+ iElement.childNodes.Item(0).childNodes.Item(i).Text + ";"
Next
vConnString = vConnString + Chr(34)
Set xDoc = Nothing
GetXMLDBCONN = vConnString
End Function
Private Sub SetXMLDBCONN(vDBConn)
Dim spmMgr As SharedPropertyGroupManager
Dim spmGroup As SharedPropertyGroup
Dim spmProp As SharedProperty
Dim groupExists As Boolean
Dim propExists As Boolean
'Create an instance of the SPM. Retrieve the
'group and property and then set the value
'-------------------------------------------------
Set spmMgr = CreateObject _
("MTxSpm.SharedPropertyGroupManager.1")
Set spmGroup = spmMgr.CreatePropertyGroup _
(Trim("spGroup"), LockSetGet, Process, groupExists)
Set spmProp = spmGroup.CreateProperty _
(Trim("spProperty"), propExists)
spmProp.Value = vDBConn
mobjContext.SetComplete
Exit Sub
ErrHandler:
If Not mobjContext Is Nothing Then
mobjContext.SetAbort
End If
Err.Raise Err.Number, "", Err.Description, ""
End Sub