Serviced Componentsand COM+

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JohnFol

    Serviced Componentsand COM+

    I have a piece of code that I want to use as a library / dll for other s/w
    developments.

    For example in VB6 land,
    1) I create MyCalculator.DL L
    2) In another project I make a reference to MyCalculator.DL L
    3) I then do something like
    Dim objMaths as MyCalculator.Ma thsFunctions
    :
    4) When I want to release the object I simply do
    Set objMaths = Nothing

    This code will work regardless of MyCalculator.DL L being hosted in Component
    Services or not.

    Now, using VB.Net I do
    1) I create MyCalculator.DL L (with the class Inheriting ServicedCompone nt)
    2) In another project I make a reference to MyCalculator.DL L
    3) I then do something like
    Dim objMaths as MyCalculator.Ma thsFunctions
    :
    But now, to release the component I understand I need to use 1 of 2 methods
    depedning on how the DLL is hosted. ie

    objMaths.Dispos e (for a std DLL)
    or ServicedCompone nt.DisposeObjec t (objMaths) if it is hosted in
    Component Services


    Is this correct, and if so, why should my "client" s/w need to be coded
    specifically for how the DLL is deployed?




  • Paul Clement

    #2
    Re: Serviced Componentsand COM+

    On Mon, 25 Apr 2005 09:13:09 GMT, "JohnFol" <OutlookExpress @WibbleObbble.C om> wrote:

    ¤ I have a piece of code that I want to use as a library / dll for other s/w
    ¤ developments.
    ¤
    ¤ For example in VB6 land,
    ¤ 1) I create MyCalculator.DL L
    ¤ 2) In another project I make a reference to MyCalculator.DL L
    ¤ 3) I then do something like
    ¤ Dim objMaths as MyCalculator.Ma thsFunctions
    ¤ :
    ¤ 4) When I want to release the object I simply do
    ¤ Set objMaths = Nothing
    ¤
    ¤ This code will work regardless of MyCalculator.DL L being hosted in Component
    ¤ Services or not.
    ¤
    ¤ Now, using VB.Net I do
    ¤ 1) I create MyCalculator.DL L (with the class Inheriting ServicedCompone nt)
    ¤ 2) In another project I make a reference to MyCalculator.DL L
    ¤ 3) I then do something like
    ¤ Dim objMaths as MyCalculator.Ma thsFunctions
    ¤ :
    ¤ But now, to release the component I understand I need to use 1 of 2 methods
    ¤ depedning on how the DLL is hosted. ie
    ¤
    ¤ objMaths.Dispos e (for a std DLL)
    ¤ or ServicedCompone nt.DisposeObjec t (objMaths) if it is hosted in
    ¤ Component Services
    ¤
    ¤
    ¤ Is this correct, and if so, why should my "client" s/w need to be coded
    ¤ specifically for how the DLL is deployed?

    Because when using COM+ there is an associated object that is created when hosting the managed code
    DLL. If this object is not released it will continue to exist under COM+.

    Not sure if there is a way to determine whether a .NET DLL is running under COM+ in order to
    determine which Dispose method to use. GetObjectContex t will do this when using the COM+ objects.


    Paul
    ~~~~
    Microsoft MVP (Visual Basic)

    Comment

    Working...