I can't find any good documentation on what the concept of a Class Loader is in the .NET Framework? What is it? Where can it be found? Does anyone know?
-
1Why do you assume there _is_ such a thing as a class loader in .NET? – John Saunders Jun 01 '10 at 06:28
-
1Someone asked me this question and had never come across it. I know the concept exists in Java and was wondering if there was an equivalent in .NET. – user118190 Jun 01 '10 at 21:06
3 Answers
In .NET assemblies are the fundamental unit of deployment. The technology that actually loads the assemblies is called Fusion. For more details on that read the .NET Fusion Workshop. Each assembly has its own class loader to load types from that assembly.
Hosting the Common Language Runtime may also be of interest.
I don't think that Class Loader in .NET holds the same importance or power as it does in Java. The loading of the class would be handled by the assembly's class loader.
Dynamic loading would usually be done by loading the assembly and then instantiating the class:
Assembly assembly = Assembly.LoadFrom("assemblyName");
Type type = assembly.GetType("className");
object x = Activator.CreateInstance(type);

- 22,566
- 4
- 68
- 94
Randy Levy's didn't answer all. Class loader did more jobs than Assembly.LoadFrom. Because there isn't a method like ‘Assembly.Unload'. The assemblies could be only unloaded by closing appdomain. Java's class loader can do lot of more than Randy Levy's answer. Here tag a better answer in stackoverflow Equivalent of Class Loaders in .NET
What do you mean? A similar concept to the Java class loaders? In .Net the concept is mapped to AppDomain (just search for AppDomain)
-
Yes, I am looking for the equivalent of Java Class Loaders! So, should I search for AppDomain and read up on it? – user118190 Jun 01 '10 at 21:07
-
**AFAIK**, they are equivalent concepts, I mean, both are used as a security boundary, types loaded in one Class Loader/App domain, cannot (in general) be used by objects in other Class Loader/App domains, etc. What exactly are you trying to accomplish? – Jun 02 '10 at 13:35
-
2I'm not familiar with Java internals but Java Class Loader and .NET AppDomain seem different to me. From Wikipedia: "The Java Classloader is a part of the Java Runtime Environment that dynamically loads Java classes into the Java Virtual Machine." and "In the Common Language Runtime, an application domain is a mechanism (similar to a process in an operating system) used to isolate executed software applications from one another so that they do not affect each other". Wouldn't the equivalent of an AppDomain be a JVM instance? – Randy Levy Jun 08 '10 at 20:29