From: Peter Duniho on
SQACSharp wrote:
>> Try look at registry variables.
>> http://stackoverflow.com/questions/199080/how-to-detect-what-net-fram...
>
> Thanks but this is only to check if the framework is installed.
>
> I want to know if application abcd.exe or blabla.dll is using the
> framework 2.0 , 3.0 or 3.5.
> You can target a specific framework in the application/dll and I need
> to know what framework version is targeted by the file at runtime. I
> can get the CLR version by getting application process and by looking
> at mscorlib.dll version, but look like there is no way to get "real"
> FRAMEWORK version when CLR version is 2

I may not understand the question entirely. But, you can load an
assembly and then call GetReferencedAssemblies() to determine which
assemblies it references. The information returned includes version
information.

For an already-running process, it should be simpler: just look at the
DLLs that are actually loaded in the process.

One of your replies in this thread seems to indicate that you are
looking for compile-time information. Specifically, rather than the
actual assembly version of DLLs referenced, you want to know the SDK
version used to compile the program. As that's a compile-time thing,
AFAIK there is no way to obtain that information from the compiled
assembly. However, there really should be no practical use for that
information either.

If you can explain what you're actually trying to accomplish, rather
than your predetermined mechanism for accomplishing it, you might get a
better answer that is more directly useful in achieving your goal.

Pete
From: SQACSharp on
At runtime,

I'm Looping on all running processes on my machine to get all
*managed* process. (*ANY* process using mscorlib.dll)

Once I get the list of managed applications running on pc

I need to determine the precise net framework version used by theses
applications.

Problem :
I know if the running application use the framework 1.0, 1.1 but the
problem is when the application use net framework 2, 3, 3.5. Since
they all use the same CLR version there is no way to distinguish them.
(Framework version not clr version)

When creating net application we can specify the target framework (2,
3 , 3.5)

I need to know what is the targeted framework of this application (not
my application)

Seems totally impossible I cant figure this out.

BTW it seems you CANT even create an application from scratch like
"Hello world, I'm running on framework 3.5" without using a
conditional compile constants or config file.... right ??

It's for a kind of spy++ tool
From: Peter Duniho on
SQACSharp wrote:
> At runtime,
>
> I'm Looping on all running processes on my machine to get all
> *managed* process. (*ANY* process using mscorlib.dll)
>
> Once I get the list of managed applications running on pc
>
> I need to determine the precise net framework version used by theses
> applications.

As I said, this is likely to be impossible.

> Problem :
> I know if the running application use the framework 1.0, 1.1 but the
> problem is when the application use net framework 2, 3, 3.5. Since
> they all use the same CLR version there is no way to distinguish them.
> (Framework version not clr version)

Applications _using_ 3.0 and 3.5 features will be using additional DLLs
that you can look for, as well as examine the versions of.

> When creating net application we can specify the target framework (2,
> 3 , 3.5)

The targeting of a framework is, as I said, a compile-time thing. It
may or may not produce observable differences in the compiled output.

> [...]
> It's for a kind of spy++ tool

Spy++ doesn't tell you what version of the compiler was used to create
the application in question, nor which version of the Windows SDK. Why
do you think that your similar tool should tell you that kind of
information about a managed executable?

Pete
From: SQACSharp on
So I will have to do a kind of partial version recognition based on
referenced dll version ;o). Thanks Peter

From: Arne Vajhøj on
On 03-05-2010 01:11, SQACSharp wrote:
>> Try look at registry variables.
>> http://stackoverflow.com/questions/199080/how-to-detect-what-net-fram...
>
> Thanks but this is only to check if the framework is installed.
>
> I want to know if application abcd.exe or blabla.dll is using the
> framework 2.0 , 3.0 or 3.5.
> You can target a specific framework in the application/dll and I need
> to know what framework version is targeted by the file at runtime. I
> can get the CLR version by getting application process and by looking
> at mscorlib.dll version, but look like there is no way to get "real"
> FRAMEWORK version when CLR version is 2

If you know which versions are on the system and you know
what versions a given app require, then what are you missing?

Arne