COM+, CRM's and Stuff

  • Thread starter Thread starter platinumbay
  • Start date Start date
P

platinumbay

Two questions:

1) I have an VB.NET application that moves files, loads them in DTS, and
updates a custom SQL database queue. I want to move everything into COM+ to
be XA compliant. I built the MSDN bank sample, and adding SQL support and
an interface, and it is a very cool sample (answered a lot of questions),
but how do I integrate my FSO CRM into the mix? How do I merge these two
worlds?

2) The application is multi-threaded, will it continue to work well in a
transactional environment. I read something about Queueing, and I don't
want to have a bottleneck when I am loading files in a multi-threaded
environment.

Thank very much,

Steve
 
Here is the code I have so far, I am getting COM errors, and other
Exceptions:

Imports System

Imports System.IO

Imports System.Reflection

Imports System.EnterpriseServices

Imports System.Runtime.Serialization

Imports System.EnterpriseServices.CompensatingResourceManager

Public Enum iStatus

None

Posting

Posted

Completed

InsufficientFunds

Failed

Exception

COMException

UnknownError

End Enum

Public Interface iaRecord

Function ToString() As String

End Interface

<Serializable()> _

Public Class aRecord

Implements iaRecord

Public Shared StartPath As String

Public Shared EndPath As String

Public Shared AppScope As Integer

Public Sub New(ByVal a As Integer, ByVal s As String, ByVal e As String)

AppScope = a

StartPath = s

EndPath = e

End Sub

Public Overrides Function ToString() As String Implements iaRecord.ToString

Return AppScope & ":" & StartPath & ":" & EndPath

End Function

End Class

Public Interface iCrmWorker

Function MoveFile(ByVal AppScope As Integer, ByVal StartPath As String,
ByVal EndPath As String) As iStatus

End Interface

<Transaction(TransactionOption.Required)> _

Public Class FSOCRM

Inherits ServicedComponent

Implements iCrmWorker

Public _ex As Exception = Nothing

Public _msg As String = "Started"

Public Function MoveFile(ByVal AppScope As Integer, ByVal StartPath As
String, ByVal EndPath As String) As iStatus Implements iCrmWorker.MoveFile

Try

_msg = "Creating Clerk"

Dim myclerk As Clerk = New Clerk(GetType(CRMCompensator), "CRMCompensator",
CompensatorOptions.AllPhases)

_msg = "Creating new aRecord"

Dim _aRecord As New aRecord(AppScope, StartPath, EndPath)

_msg = "Writing Log Record"

myclerk.WriteLogRecord(_aRecord.ToString)

_msg = "Forcing Log"

myclerk.ForceLog()

_msg = "Getting FileInfo"

Dim fInfo As New FileInfo(StartPath)

_msg = "Moving File"

fInfo.MoveTo(EndPath)

_msg = "Done"

'TODO - DO SQL STUFF HERE TO MARK AS MOVED, SHOULD BE TRANSACTIONAL BY
NATURE

ContextUtil.SetComplete()

Return iStatus.Completed

Catch ex As Runtime.InteropServices.COMException

Me._ex = ex

Debug.WriteLine("##COMexception: " & ex.ToString)

ContextUtil.SetAbort()

Return iStatus.COMException

Catch ex As Exception

Me._ex = ex

Debug.WriteLine("##exception: " & ex.ToString)

ContextUtil.SetAbort()

Return iStatus.Exception

Catch

Debug.WriteLine("##unknown error")

ContextUtil.SetAbort()

Return iStatus.UnknownError

End Try

End Function

End Class

Public Interface iCRMCompensator

Sub BeginPrepare()

Function PrepareRecord(ByVal rec As LogRecord) As Boolean

Function EndPrepare() As Boolean

Sub BeginCommit(ByVal fRecovery As Boolean)

Function CommitRecord(ByVal rec As LogRecord) As Boolean

Sub EndCommit()

Sub BeginAbort(ByVal fRecovery As Boolean)

Function AbortRecord(ByVal rec As LogRecord) As Boolean

Sub EndAbort()

Function RecFromString(ByVal s As String) As aRecord

End Interface

Public Class CRMCompensator

Inherits Compensator

Implements iCRMCompensator

Dim bBeginPrepareCalled As Boolean = False

Dim bPrepareRecordCalled As Boolean = False

Dim bBeginCommitCalled As Boolean = False

Dim bCommitRecordCalled As Boolean = False

Dim bBeginAbortCalled As Boolean = False

Dim bAbortRecordCalled As Boolean = False

Dim StartPath As String

Dim EndPath As String

Public Overrides Sub BeginPrepare() Implements iCRMCompensator.BeginPrepare

bBeginPrepareCalled = True

End Sub

Public Overrides Function PrepareRecord(ByVal rec As LogRecord) As Boolean
Implements iCRMCompensator.PrepareRecord

Dim _aRecord As aRecord = RecFromString(rec.ToString)

Debug.WriteLine("prepare: " & _aRecord.ToString)

StartPath = _aRecord.StartPath

EndPath = _aRecord.EndPath

bPrepareRecordCalled = True

Return False

End Function

Public Overrides Function EndPrepare() As Boolean Implements
iCRMCompensator.EndPrepare

If Not bBeginPrepareCalled Then Return False

If Not bPrepareRecordCalled Then Return False

If StartPath = "" Or EndPath = "" Then Return False

Return True

End Function

Public Overrides Sub BeginCommit(ByVal fRecovery As Boolean) Implements
iCRMCompensator.BeginCommit

bBeginCommitCalled = True

End Sub

Public Overrides Function CommitRecord(ByVal rec As LogRecord) As Boolean
Implements iCRMCompensator.CommitRecord

Dim o As aRecord = RecFromString(rec.ToString)

Dim fInfo As New FileInfo(o.StartPath)

fInfo.MoveTo(o.EndPath)

bCommitRecordCalled = True

Return True

End Function

Public Overrides Sub EndCommit() Implements iCRMCompensator.EndCommit

If Not bBeginCommitCalled Then Return

If Not bCommitRecordCalled Then Return

If StartPath = "" Or EndPath = "" Then Return

End Sub

Public Overrides Sub BeginAbort(ByVal fRecovery As Boolean) Implements
iCRMCompensator.BeginAbort

bBeginAbortCalled = True

End Sub

Public Overrides Function AbortRecord(ByVal rec As LogRecord) As Boolean
Implements iCRMCompensator.AbortRecord

bAbortRecordCalled = True

Dim _aRecord As aRecord = RecFromString(rec.ToString)

Debug.WriteLine("abort: " & _aRecord.ToString)

StartPath = _aRecord.StartPath

EndPath = _aRecord.EndPath

Dim fInfo As New FileInfo(EndPath)

fInfo.MoveTo(StartPath)

Return True

End Function

Public Overrides Sub EndAbort() Implements iCRMCompensator.EndAbort

If Not bBeginAbortCalled Then Return

If Not bAbortRecordCalled Then Return

If StartPath = "" Or EndPath = "" Then Return

End Sub

Public Function RecFromString(ByVal s As String) As aRecord Implements
iCRMCompensator.RecFromString

Dim newS() As String = s.Split(":"c)

Dim _aRecord As New aRecord(CInt(newS(0)), newS(1), newS(2))

Return _aRecord

End Function

End Class


In the Event Viewer, I get the following error(s):

The system has called the CRM Compensator custom component and that
component has returned an error. This indicates a problem with the CRM
Compensator component. Notify the developer of the CRM Compensator component
that this failure has occurred.

Component Prog ID: {37c543e9-bf6b-35ed-977c-f2ecf976fbd0}

Method Name: ICrmCompensator::AbortRecord

Server Application ID: {607E9757-6D53-4D82-9E70-9E88BB27D113}

Server Application Instance ID:

{1A1BBF99-9B4F-4A11-8C41-76B6E01BFB95}

Server Application Name: BankComponent

The serious nature of this error has caused the process to terminate.

Error Code = 0x80004002 : No such interface supported

COM+ Services Internals Information:

File: d:\nt\com\complus\src\comsvcs\crm\crmclerkobj.cpp, Line: 3578

Comsvcs.dll file version: ENU 2001.12.4720.130 shp

For more information, see Help and Support Center at
http://go.microsoft.com/fwlink/events.asp.


Of course, being that it uses reflection to call the COM+ app, I can't debug
to see where the error is, and the referenced .cpp file doesn't exist in
that path.

Any thoughts on if there is something I am doing wrong, or how to further
debug it?
 
Hi,

Currently I am contacting related person who could help you on it. We will
reply here with more information as soon as possible.
If you have any more concerns on it, please feel free to post here.


Thanks for your understanding!

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
It is hard to tell the reason for the CRM error by just looking at the
eventlog error. We need more information. We need a Reproducible code to
further troubleshoot this issue.
- service code (I assume it is the linked VB.Net) (bits, symbol).
- installation script.
- client codes (bits, symbol).

BTW, we scan thru the code and like to give the following suggestion.
- the aRecord class member (startpath, ...) should not be shared.
- don't need to do tostring on LogRecord. Client can get the object
directly by record.Record. We will serialize that for you.
thanks,
Lalitha
Microsoft COM+ Developer Support
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Steve,

Is there any further question on this issue? If so, please feel free to let
us know.

Thanks,

Luke
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top