Dynamically loading an assembly which expects GAC assemblies which are not actually available?

StackOverflow https://stackoverflow.com/questions/4777201

  •  23-10-2019
  •  | 
  •  

Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top