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
  • 24,474
  • 29
  • 82
  • 106

3 Answers3

4

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

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • 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
  • 47,395
  • 5
  • 59
  • 72
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
  • 115,091
  • 17
  • 196
  • 297