473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Passing a DLL vs. Reinstantiating it

Tom
I have a main VB.NET program which instantiates a number of other VB.NET
DLLs. This DLLs all use routines from a 'base' DLL (which contains a number
of common routines); so currently I reinstantiate that 'base' DLL in every
one of my called DLLs.

The question is: Would it be better if I instantiated the 'base' DLL in the
main program, then passed a reference of the 'base' to each of my other
DLLs? Or is .NET smart enough to use same copy of the 'base' DLL when it
gets instantiated in each of my DLLs? (in other words, even though the same
'base' DLL is instantiated many times in different DLLs, VB.NET keeps only
one copy in memory of the 'base' DLL and they all share that copy).

Just wondering if going through the work of passing a reference to my 'base'
DLL is worth it.... Thanks.

Tom
Nov 20 '05 #1
2 1326
Of course not. All the instances are different. Each one might have
different properties set, etc, and that woudl make it behave differently.
If all instances of the same class, were actually just one instance
internally, then nothing would ever work. Imagine having 2 string
variables - but then somehow internally, .NET would treat them as one? How
would that work?

If the methods in your class don't depend on class state, and just on the
arguments to each of the methods, then you can make them all Shared. This
means you call the method through the class name itself, as opposed to
through an instance of that class. That means that no instance of the class
is ever instantiated, and you are not wasting resources by creating objects
that don't really need to be there.

"Tom" <to*@nospam.com> wrote in message
news:On**************@tk2msftngp13.phx.gbl...
I have a main VB.NET program which instantiates a number of other VB.NET
DLLs. This DLLs all use routines from a 'base' DLL (which contains a number of common routines); so currently I reinstantiate that 'base' DLL in every
one of my called DLLs.

The question is: Would it be better if I instantiated the 'base' DLL in the main program, then passed a reference of the 'base' to each of my other
DLLs? Or is .NET smart enough to use same copy of the 'base' DLL when it
gets instantiated in each of my DLLs? (in other words, even though the same 'base' DLL is instantiated many times in different DLLs, VB.NET keeps only
one copy in memory of the 'base' DLL and they all share that copy).

Just wondering if going through the work of passing a reference to my 'base' DLL is worth it.... Thanks.

Tom

Nov 20 '05 #2
Of course not. All the instances are different. Each one might have
different properties set, etc, and that woudl make it behave differently.
If all instances of the same class, were actually just one instance
internally, then nothing would ever work. Imagine having 2 string
variables - but then somehow internally, .NET would treat them as one? How
would that work?

If the methods in your class don't depend on class state, and just on the
arguments to each of the methods, then you can make them all Shared. This
means you call the method through the class name itself, as opposed to
through an instance of that class. That means that no instance of the class
is ever instantiated, and you are not wasting resources by creating objects
that don't really need to be there.

"Tom" <to*@nospam.com> wrote in message
news:On**************@tk2msftngp13.phx.gbl...
I have a main VB.NET program which instantiates a number of other VB.NET
DLLs. This DLLs all use routines from a 'base' DLL (which contains a number of common routines); so currently I reinstantiate that 'base' DLL in every
one of my called DLLs.

The question is: Would it be better if I instantiated the 'base' DLL in the main program, then passed a reference of the 'base' to each of my other
DLLs? Or is .NET smart enough to use same copy of the 'base' DLL when it
gets instantiated in each of my DLLs? (in other words, even though the same 'base' DLL is instantiated many times in different DLLs, VB.NET keeps only
one copy in memory of the 'base' DLL and they all share that copy).

Just wondering if going through the work of passing a reference to my 'base' DLL is worth it.... Thanks.

Tom

Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Dave | last post by:
I'm currently working on a small project (admitedly for my CS class) that compares the time difference between passing by value and passing by reference. I'm passing an array of 50000 int's. ...
58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
9
by: Just Me | last post by:
PARAFORMAT2 is a structure that SendMessage will return stuff in. Is the "ref" correct or since only a pointer is being passed should it be by value? Suppose I was passing data rather then...
8
by: Dennis Myrén | last post by:
I have these tiny classes, implementing an interface through which their method Render ( CosWriter writer ) ; is called. Given a specific context, there are potentially a lot of such objects,...
0
by: Tom | last post by:
I have a main VB.NET program which instantiates a number of other VB.NET DLLs. This DLLs all use routines from a 'base' DLL (which contains a number of common routines); so currently I...
22
by: Arne | last post by:
How do I pass a dataset to a webservices? I need to submit a shoppingcart from a pocket PC to a webservice. What is the right datatype? II have tried dataset as a datatype, but I can't get it to...
6
by: MSDNAndi | last post by:
Hi, I get the following warning: "Possibly incorrect assignment to local 'oLockObject' which is the argument to a using or lock statement. The Dispose call or unlocking will happen on the...
12
by: Andrew Bullock | last post by:
Hi, I have two classes, A and B, B takes an A as an argument in its constructor: A a1 = new A(); B b = new B(a1);
4
by: Deckarep | last post by:
Hello fellow C# programmers, This question is more about general practice and convention so here goes: I got into a discussion with a co-worker who insisted that as a general practice all...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.