COM+ And VB


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: COM+ And VB

  1. #1
    Tushar Mistry Guest

    COM+ And VB


    I am a Begineer of COM. I am using Windows 2000 and VB 6.0
    I have created a Dll "ComArithmatic" using VB 6 in
    which I have made 2 Functions "Add" and "Multiply".
    I want to know what is the difference betn

    1. CreateObject("...") and
    Set x = CreateObject("ComArithmatic.Arithmatic")
    2. GetObjectContext.CreateInstance("...") Function
    Set y = GetObjectContext()
    Set x = y.CreateInstance("ComArithmatic.Arithmatic")
    Where x is decalred as Object and y is declared as ObjectContext.

    The 1st option works well but can it be called COM application ?

    When I tried to use the 2nd option the variabel y is set to Nothing.
    Why GetObjectContext returns Null ? Not that I have already imported
    the dll file into COM+ package using Component Services(MTS Explorer).
    Please Help


  2. #2
    Paul Clement Guest

    Re: COM+ And VB

    On 29 Apr 2002 01:11:50 -0800, "Tushar Mistry" <tumistry@yahoo.com> wrote:


    I am a Begineer of COM. I am using Windows 2000 and VB 6.0
    I have created a Dll "ComArithmatic" using VB 6 in
    which I have made 2 Functions "Add" and "Multiply".
    I want to know what is the difference betn

    1. CreateObject("...") and
    Set x = CreateObject("ComArithmatic.Arithmatic")
    2. GetObjectContext.CreateInstance("...") Function
    Set y = GetObjectContext()
    Set x = y.CreateInstance("ComArithmatic.Arithmatic")
    Where x is decalred as Object and y is declared as ObjectContext.

    The 1st option works well but can it be called COM application ?

    When I tried to use the 2nd option the variabel y is set to Nothing.
    Why GetObjectContext returns Null ? Not that I have already imported
    the dll file into COM+ package using Component Services(MTS Explorer).
    Please Help

    If you are using COM+ CreateInstance is no longer required. It's a holdover (for backward
    compatibility) from MTS. In COM+ CreateInstance and CreateObject do the same thing.

    I would highly recommend you use CreateObject instead. Then, all you need to do is set the object
    context in your component and call the appropriate SetComplete or SetAbort methods at the end of
    your method calls to release the instance:

    Dim ctxObject As COMSVCSLib.ObjectContext

    Set ctxObject = COMSVCSLib.GetObjectContext()

    '.......
    '.......

    If OK
    ctxObject.SetComplete
    Else
    ctxObject.SetAbort
    End If


    Paul ~~~ pclement@ameritech.net
    Microsoft MVP (Visual Basic)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center