Serviced Componentsand COM+

  • Thread starter Thread starter JohnFol
  • Start date Start date
J

JohnFol

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.DLL
2) In another project I make a reference to MyCalculator.DLL
3) I then do something like
Dim objMaths as MyCalculator.MathsFunctions
:
4) When I want to release the object I simply do
Set objMaths = Nothing

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

Now, using VB.Net I do
1) I create MyCalculator.DLL (with the class Inheriting ServicedComponent)
2) In another project I make a reference to MyCalculator.DLL
3) I then do something like
Dim objMaths as MyCalculator.MathsFunctions
:
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.Dispose (for a std DLL)
or ServicedComponent.DisposeObject (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?
 
¤ 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.DLL
¤ 2) In another project I make a reference to MyCalculator.DLL
¤ 3) I then do something like
¤ Dim objMaths as MyCalculator.MathsFunctions
¤ :
¤ 4) When I want to release the object I simply do
¤ Set objMaths = Nothing
¤
¤ This code will work regardless of MyCalculator.DLL being hosted in Component
¤ Services or not.
¤
¤ Now, using VB.Net I do
¤ 1) I create MyCalculator.DLL (with the class Inheriting ServicedComponent)
¤ 2) In another project I make a reference to MyCalculator.DLL
¤ 3) I then do something like
¤ Dim objMaths as MyCalculator.MathsFunctions
¤ :
¤ 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.Dispose (for a std DLL)
¤ or ServicedComponent.DisposeObject (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. GetObjectContext will do this when using the COM+ objects.


Paul
~~~~
Microsoft MVP (Visual Basic)
 

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