How to query an .NET assembly's required framework (not CLR) version?
- by Bonfire Burns
Hi,
we are using some kind of plug-in architecture in one of our products
(based on .NET). We have to consider our customers or even 3rd party
devs writing plug-ins for the product. The plug-ins will be .NET
assemblies that are loaded by our product at run-time. We have no
control about the quality or capabilities of the external plug-ins
(apart from checking whether they implement the correct interfaces).
So we need to implement some kind of safety check while loading the
plug-ins to make sure that our product (and the hosting environment)
can actually host the plug-in or deliver a meaningful error message
("The plug-in your are loading needs .NET version 42.42 - the hosting
system is only on version 33.33.").
Ideally the plug-ins would do this check internally, but our
experience regarding their competence is so-so and in any case our
product will get the blame, so we want to make sure that this "just works". Requiring the plug-in developers to provide the info in the metadata or to explicitly provide the information in the interface is considered "too complicated".
I know about the Assembly.ImageRuntimeVersion property. But to my
knowledge this tells me only the needed CLR version, not the framework
version. And I don't want to check all of the assembly's dependencies
and match them against a table of "framework version vs. available
assemblies".
Do you have any ideas how to solve this in a simple and maintainable
fashion?
Thanks & regards, Bon