When would using Assembly.LoadFrom or Assembly.LoadFile be appropriate?
Asked
Active
Viewed 1.2k times
17
-
Have you read these: http://msdn.microsoft.com/en-us/library/system.reflection.assembly.loadfrom.aspx and http://msdn.microsoft.com/en-us/library/system.reflection.assembly.loadfile.aspx? What did you understand? What didn't you understand? – R. Martinho Fernandes Apr 20 '11 at 10:06
-
1We need more context to answer a question like this. Which one is more appropriate depends on what you're trying to do. – Cody Gray - on strike Apr 20 '11 at 10:13
-
3Allready been answered in http://stackoverflow.com/questions/1477843/difference-between-loadfile-and-loadfrom-with-net-assemblies Check it. – Wolf5 Apr 20 '11 at 10:08
1 Answers
5
Main difference is that LoadFrom
can be redirected to another assembly at a different path but with same identity if it's already loaded. LoadFile
just loads exactly what the caller requested.
So, you should use LoadFrom
when you need to prevent loading second assembly with same identity or just loading assembly twice.
Respectively, you should use LoadFile
only if you need to load assembly twice or load two assemblies with same identifier.
You can read more in this article LoadFile vs LoadFrom.

Baldo
- 3
- 2

Andrey Tretyak
- 3,043
- 2
- 20
- 33