Jack Kada
Jack Kada

Reputation: 25212

User Defined ClassLoader In C#

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

Upvotes: 5

Views: 980

Answers (3)

VinayC
VinayC

Reputation: 49195

.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.

Upvotes: 1

leppie
leppie

Reputation: 117250

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.

Upvotes: 0

SLaks
SLaks

Reputation: 887459

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

Upvotes: 4

Related Questions