By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,743 Members | 1,028 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,743 IT Pros & Developers. It's quick & easy.

Delayed loading dependent assemblies when start an .Net application

P: n/a
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.

Mar 6 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi,

<wz*******@gmail.comwrote in message
news:11*********************@64g2000cwx.googlegrou ps.com...
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.


Mar 6 '07 #2

P: n/a
The CLR will load an assembnly only when it is absolutely necessary. The
delay-loading is built in. (check
http://www.awprofessional.com/articl...&seqNum=5&rl=1 for
a more detailed discussion of CLR loader.) You do not need to do anything
(nor you can).

By adding reference you are not forcing the assembly to be loaded at
startup.
If your code does not use any type in it, it will not get loaded.

<wz*******@gmail.comha scritto nel messaggio
news:11*********************@64g2000cwx.googlegrou ps.com...
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.

Mar 6 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.