Click to See Complete Forum and Search --> : Porting COM from NT to W2K
cnew
July 17th, 2001, 12:26 AM
Greetings,
I have been asked to look into porting an MTS/COM application from WinNT 4.0 to Win2000. In viewing previous posts, it would appear that it might be possible to simply register the existing component using Component Services. If I understand, COM+ is and encapsulation of MTS & COM, which supports this line of thought.
Is this all that would be required?
Would there not be some sort of re-compile required?
Also, I notice that when I was in the Component Services and looking at registering the DLL, an option came up asking whether I wanted to have the component run when the current user is logged in or a user whom I could choose. This would suggest that if the Server went down, when it came back up (unattended) that the component would not start automatically. I want the component to start automatically.
If this is true, how should it be registered?
Any help or direction to the information to help with this is greatly needed and appreciated.
Chris.
Cakkie
July 17th, 2001, 01:38 AM
Normally, your MTS components should run in COM+, with the exception of some advanced things, like tracking security using the components (using the ObjectContext and stuff, so this also applies the components using transactions, but handeling them manually, using SetAbort and stuff)
The second thing, concerning the user it runs under, is not as you see it. If you select the option 'run as logged on user', the object runs in the security context of the user making the call, so if I'm logged in as Administrator (that is on the PC i'm at, not nesccecary the PC running the COM+ environment), the component could be able to do anything on my system (like changing configuration, deleting files, everything). If I'm logged in as Guest, I would be able to do virtually nothing.
This actually is part of COM+ security, which can go very deep, to even saying that a user can execute a method of a component or not.
Tom Cannaerts
slisse@planetinternet.be
Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
cnew
July 17th, 2001, 10:30 AM
Tom,
Thank-you for responding. In reviewing the VB project code, I find that there are several instances of ObjectContext being used in a number of functions of all classes. In addition, nearly all classes have the MTSTransactionMode property set to RequiresTransaction.
From what you have stated, this would suggest that this DLL cannot be simply registered under Win2K. If this is the case, could you provide some direction or general outline as to what is required to make this happen? I have a working understanding of COM, but COM+ is still more theory than practice.
Below I have included a code snippet. This is the typical outline for each function in the project. Would you give me an idea as to what needs to happen to port to COM+ and if possible, could you direct me to a good book that explains (in relative detail) the differences between COM/COM+ as well as some of the issues that need to be addressed when attempting these types of upgrades and changes.
Again, Thank-you.
Chris.
public Function GetData(sWhereClause as string, optional lMaxRecs as Long) as ADODB.Recordset
on error GoTo GetData_Err
'Declarations
Dim oDS as DataServices
Dim oContext as ObjectContext
Dim rstData as ADODB.Recordset
Dim sSQL as string
'Instantiations
set oContext = GetObjectContext
set oDS = oContext.CreateInstance("KDN.Services")
'If the WHERE clause has Primary Key in it
'then substitute the actual key column
.
.
.
'Define the SQL Statement
.
.
.
'Call out to Services to get the data
If IsMissing(lMaxRecs) then
set rstData = oDS.GetData(sSQL, cRootTableName, cPKeyFieldName)
else
set rstData = oDS.GetData(sSQL, cRootTableName, cPKeyFieldName, lMaxRecs)
End If
'Successful completion - Return the data
set GetData = rstData
oContext.SetComplete
'cleanup
set oDS = nothing
Exit Function
GetData_Err:
'This code is executed if this method, or one of the subordinate method calls
'has failed, and must or has SetAbort (aborted the transaction)
'Tell MTS to abort the transaction
GetObjectContext.SetAbort
'Forward the error on to caller (another MTS object or client),
'with any additional error messages appended to the description
Err.Raise Err.Number, Err.Source, Err.Description
End Function
Spectre
July 17th, 2001, 06:27 PM
You were correct in the beginning when you suggested that you might have to re-compile your objects. The reference to the MTX object that you used under NT is no longer available. It is called instead "COM+ Services Type Library". Once you have changed the reference, you can save and re-compile. Your objects should be ready at that point to work under Win2K.
Hope this helps.
Spectre
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.