In our application, we have the need to dynamically load 3rd-party assemblies where we do not know in advance all released assembly version numbers. All we know is, for example, that the major version number for the assembly must be "12". On a PC, multiple versions of the same assembly may be installed, having both higher and lower major version numbers.
I.e. we would need something like
Assembly myAssembly = Assembly.Load("SampleAssembly, Version=12.*.*.*");
and if the assembly versions 11.1.2.3, 12.7.6.5, and 13.9.8.7 are installed, it should load version 12.7.6.5.
I.e. it should be possible to specify wildcards for version number components and it also should be possible to omit Culture
and PublicKeyToken
.
When we do this with Assembly.Load()
, we get a FileNotFoundException
.
We cannot use Assembly.LoadWithPartialName()
because it always loads the assembly with the highest version number, but we want a specific major version number instead, which possibly is less than the greatest installed assembly version number.
Is it possible to do this?