Determine framework version used by an application or a .dll

S

SQACSharp

Hi,

Is there a way to determine if an application (currently running
in windows) is using the 3.0, 3.5 net framework??

I already tried several methods and lost many hours on this but I
always get the CLR version and not the "real" framework version

How do I get the used framework version (or the target framework) of
an application?

Thanks,
 
F

Family Tree Mike

Hi,

Is there a way to determine if an application (currently running
in windows) is using the 3.0, 3.5 net framework??

I already tried several methods and lost many hours on this but I
always get the CLR version and not the "real" framework version

How do I get the used framework version (or the target framework) of
an application?

Thanks,

3.0 and 3.5 use additional dlls on top of the 2.0 CLR. If you aren't
using the new dlls to the later version, it shouldn't matter if they are
installed.

Now .Net 4.0 will report a different number for Environment.Version.
But you didn't ask about that version.
 
S

SQACSharp

3.0 and 3.5 use additional dlls on top of the 2.0 CLR.  If you aren't
using the new dlls to the later version, it shouldn't matter if they are
installed.

An application can be 2.0,3.0 and 3.5 without using/referencing any
new dll when targeting a particular framework. In this case we cant
check the referenced dll to identify the targeted version.
 
A

Arne Vajhøj

S

SQACSharp

Try look at registry variables.

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
 
P

Peter Duniho

SQACSharp said:
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
 
S

SQACSharp

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
 
P

Peter Duniho

SQACSharp said:
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
 
S

SQACSharp

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

Arne Vajhøj

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
 
A

Arne Vajhøj

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.

Processes are not really using "a framework version". They are running
under a specific CLR version and using certain assemblies.

Do you define a framework 3.0 app as an app that:
- runs in 2.0 CLR
- does require one or more assemblies that started shipping with 3.0
- does not require any assemblies that started shipping with 3.5
?

Arne
 
S

SQACSharp

If you know which versions are on the system and you know
what versions a given app require, then what are you missing?
That's what I need identify the version of an individual application.
(not my application, any possible .net application)
Do you define a framework 3.0 app as an app that:
- runs in 2.0 CLR
- does require one or more assemblies that started shipping with 3.0
- does not require any assemblies that started shipping with 3.5
Run 2.0 clr, I can guess the version by looking at reffered
assemblies but nothing prevent a net 3.5 application to not using >2.0
framework stuff so there is no "good" way to identify that version.
 
A

Arne Vajhøj

That's what I need identify the version of an individual application.
(not my application, any possible .net application)

Run 2.0 clr, I can guess the version by looking at reffered
assemblies but nothing prevent a net 3.5 application to not using>2.0
framework stuff so there is no "good" way to identify that version.

What makes an app a 3.5 app if if is not using any 3.0 and 3.5
assemblies?

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top