[Reflection] Can find types without loading assemblies?

L

Leonardo Spina

I would need to iterate through all the assemblies I can find on mi pc and
use only those which implement a specific interface I wrote.
The only way I found is to load one by one all the assemblies I find and
iterate through types and interfaces.
It works but memory usage hugely increases!

Is there another way to do this? (at least a way to unload unuseful
assemblies after loading them?)

Thanks in advance!
 
J

Jon Skeet [C# MVP]

Leonardo Spina said:
I would need to iterate through all the assemblies I can find on mi pc and
use only those which implement a specific interface I wrote.
The only way I found is to load one by one all the assemblies I find and
iterate through types and interfaces.
It works but memory usage hugely increases!

Is there another way to do this? (at least a way to unload unuseful
assemblies after loading them?)

Well, without writing your own library to read assembly files (or using
a 3rd party one - there's one available, but I can't remember anything
about it) you're stuck with loading the assembly in the normal way.
However, you can load it into a different AppDomain, and unload the
AppDomain when you're finished with it.
 
J

Jon Skeet [C# MVP]

Leonardo Spina said:
What do you mean by "your own library to read assembly files"?

I mean that the format for assemblies is publicised, and you can read
them without loading them as assemblies into the CLR. It's just a bit
of a pain to do.
 

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