0

What happens if an application tries to load an assembly which has references to assemblies in the GAC and these assemblies are not available on the machine?

Basically I want to rely on assembly loading succeeding to assume that the referenced assemblies are available on the end users machine. Am I being dense?

NVM
  • 5,442
  • 4
  • 41
  • 61

2 Answers2

1

If the runtime isn't able to load a required assembly, it will throw an exception (doesn't matter if you try to load it at startup or dynamically via Assembly.Load()). So if you don't get an exception, you can expect the classes to be avaiable.

Femaref
  • 60,705
  • 7
  • 138
  • 176
  • What do you mean by 'completely independent' I am loading it via Assembly.Load() – NVM Jan 23 '11 at 23:18
1

Basically I want to rely on assembly loading succeeding

It never pays to rely on something like this! Anyway, to answer your question, you'll get an exception. If an exception is not thrown then the dependent assemblies have been loaded. If an exception is thrown, then either they're not there, or some other problem has occurred.

Moo-Juice
  • 38,257
  • 10
  • 78
  • 128
  • "It never pays to rely on something like this!" Why? – NVM Jan 23 '11 at 23:24
  • I am not concerned about failure cases. I just need a 'guarantee' that if it loads everything it references is available. – NVM Jan 23 '11 at 23:30
  • @NVM, well yes if everything loads then everything it references is available. If it doesn't load, something is wrong! I was just highlighting the point of your question that says you want to rely on something that is not necessarily reliable. However, in the context of what you want you can safely ignore that :) – Moo-Juice Jan 23 '11 at 23:32