Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Component Services / November 2004

Tip: Looking for answers? Try searching our database.

Thoughts on ServicedComponents and the Construct() method?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jim Bancroft - 17 Nov 2004 17:08 GMT
Hi everyone,

   I'm creating a serviced component in C#, and was thinking about calling
the Construct() method to cache a string in a local variable, for later use.
In VB6 I had it burned into me that caching values in a COM+ component
wasn't maybe the best idea, given how COM+ and JIT worked.  I was told that
with JIT you're not guaranteed to use the same component between method
calls, so trying to hold state in a variable is asking for trouble.

   Was that line of reasoning correct, and if so, does it hold in .Net as
well, and should I avoid caching a string in the Construct method because of
it?  Thanks,

    -Jim
Klaus H. Probst - 18 Nov 2004 22:03 GMT
There is no difference between VB6 and .NET because the technology (COM+) is
exactly the same. A ServicedComponent is just a fancier way to implement
IObjectControl.

As for how it works, you're right that you're never guaranteed the same
instance, not should you ever expect that. However, you're mixing two
concepts. IObjectConstruct is just a feature of COM+ where your
implementation gets an arbitrary string every time an instance of it is
created. I don't see how this is related to state or caching. You should
never cache the string value for the simple reason that you'll get it every
time you activate. You can of course save the string value to a scoped
instance variable in your class and use it later during the call sequence
that activated your object instance to begin with.

Signature

Klaus H. Probst, MVP
  http://www.vbbox.com/

> Hi everyone,
>
[quoted text clipped - 10 lines]
>
>      -Jim

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.