5

Inspired by this question why do we need user defined classloader in java

Does C# have a way of defining a way to load classes and dlls on demand

Community
  • 1
  • 1
Jack Kada
  • 23,374
  • 29
  • 79
  • 105

3 Answers3

4

You can handle the AppDomain.AssemblyResolve event to manually load assemblies that the runtime cannot locate by itself.

SLaks
  • 837,282
  • 173
  • 1,862
  • 1,933
  • Hehe, I understood the question wrong then. I was thinking she/he wants to load the class manually (into the heap/memory) :) – leppie Aug 24 '10 at 12:18
1

.NET offers a lot of options for resolving/configuring assembly/type names while loading. But ultimately, look at Assembly.Load & Assembly.LoadFrom methods - you may even load types from some custom storage using these methods.

VinayC
  • 44,892
  • 5
  • 56
  • 69
0

No, and why would you want something like that?

The only reason I can think of is for injection/mocking.

For that you would use the .NET profiler API, and rewrite IL on the fly.

leppie
  • 112,162
  • 17
  • 191
  • 293