Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Confused about multiple versions of .NET

Status
Not open for further replies.

DeveloperJr

Programmer
Mar 10, 2007
25
US

I have an assembly that references two different versions of mscorlib.dll. Is this possible? Which one of them gets loaded and how can I tell. Is anyone here familiar with multi-version under the hood? If so, please share or point me to a good resource.
 
Multiple versions of a dll are handled through the GAC. Basically, what happens is when an assembly calls a dll that's in the cache, it also tells the system what version of the dll it wants.

There can be multiple versions of the same named dll within the Assembly folder (IMS, it's \windows\system\assembly). The version number provides the uniqueness and gives the OS the ability to seperate them.

When you add a reference to an assembly from within your project, it'll mark the current version that's on your system as what it wants. If the system can find that version or newer, then it will load it. If not, then it will give you an error.

im in ur stakz, overflowin ur heapz!
 
Thanks for your reply. The point I don’t fully understand is when we have an assembly compiled using a recent version of .NET platform – say 3.0 – lets call it Assembly X with a reference to an assembly from .NET platform 1.x and for the sake of this conversation lets call it Assembly Y. I don’t mean that the assembly Y was compiled by .NET platform 1.x. what I mean is that Assembly Y is PART of the .NET platform 1.x like System.dll for example. Now, when Assembly X instanciate a type in Y, does Y use the System in 1.x – the one it has reference to or it uses the one in 3.0?
 
The default action is to use the exact verson you referenced in Assembly X project file. If that one isn't available, it will attempt to find a newer version.

There's also an option to only accept the version that you specified. Typically, the only time that you would use this option is if the assembly you're referencing comes out with an update and does not provide backwards compatibility.

im in ur stakz, overflowin ur heapz!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top