A
Aleksander Oven
Hi,
I'm building a native application that will host managed 3rd-party
assemblies. Before loading each assembly, I'd like to check if the
required CLR and .NET version are present, and display a warning if
it turns out they're not.
Using the GetFileVersion unmanaged API gets me the CLR version that
assembly was linked against when it was built. For assemblies built with
VS2008, this will almost invariably be v2.0.50727, since this is the
latest CLR available (for now).
As it turns out, this is not sufficient...
Assemblies might be using some of the features that weren't made
available before .NET framework v3.x (for example LINQ), which means
that the "Target framework" property had to be set to, say v3.5, when
building those assemblies. However, GetFileVersion still returns
v2.0.50727 even in such cases.
This means that my check might give a false positive if it finds the
v2.0.50727 .NET framework installed, because it won't know it should
actually check for v3.5.
So the question is: do assemblies carry the information about the
required .NET framework version as well as the required CLR version?
If not (most probable to me), what else can I do to implement a safe
check?
I'm building a native application that will host managed 3rd-party
assemblies. Before loading each assembly, I'd like to check if the
required CLR and .NET version are present, and display a warning if
it turns out they're not.
Using the GetFileVersion unmanaged API gets me the CLR version that
assembly was linked against when it was built. For assemblies built with
VS2008, this will almost invariably be v2.0.50727, since this is the
latest CLR available (for now).
As it turns out, this is not sufficient...
Assemblies might be using some of the features that weren't made
available before .NET framework v3.x (for example LINQ), which means
that the "Target framework" property had to be set to, say v3.5, when
building those assemblies. However, GetFileVersion still returns
v2.0.50727 even in such cases.
This means that my check might give a false positive if it finds the
v2.0.50727 .NET framework installed, because it won't know it should
actually check for v3.5.
So the question is: do assemblies carry the information about the
required .NET framework version as well as the required CLR version?
If not (most probable to me), what else can I do to implement a safe
check?