Delayed loading dependent assemblies when start an .Net application

W

wzhao2000

Back in COM time, it's possible to use #import statement in cpp to
load COM object type info and use it at coding time. When the
application is started, the underlying COM DLL will not be loaded
until that part of code is called.

Is there a similar thing in .Net (C#) application ?

When I create C# application, I need to add reference to another
assembly if I want to use its classes (I don't want to use reflection
here). But this will also add dependency on that assembly. The
assembly will be loaded when my application starts. Is there a way to
delay the loading of dependent assemblies only when the code using it
is called?

T.I.A.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Back in COM time, it's possible to use #import statement in cpp to
load COM object type info and use it at coding time. When the
application is started, the underlying COM DLL will not be loaded
until that part of code is called.

Is there a similar thing in .Net (C#) application ?

When I create C# application, I need to add reference to another
assembly if I want to use its classes (I don't want to use reflection
here). But this will also add dependency on that assembly. The
assembly will be loaded when my application starts. Is there a way to
delay the loading of dependent assemblies only when the code using it
is called?

You could figure out something using like a plug-in pattern, but do you
really need to delay it?

You can always delay the creation of instances until the last moment you
need it, but loading the assembly has not that much of overload to justify
delaying its load.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top