Can't taget particular .NET runtime

S

Scott M.

When attempting to target a specific version of the .NET Framework in my
application configuration file, I get an error saying that: "To run this
application, you must first install one of the following versions of the.NET
framework:..." and then it lists the version that I targetted in my config
file.

I am building this with VS 2008 and the 3.5 framework, but am not using or
referencing any assemblies that are specific to 3.5 - just a very basic
class library project.

I DO have all the prior versions of the framework installed (including the
one I'm targetting in my config file).

What do you think?
 
J

Jeroen Mostert

Scott said:
When attempting to target a specific version of the .NET Framework in my
application configuration file, I get an error saying that: "To run this
application, you must first install one of the following versions of the.NET
framework:..." and then it lists the version that I targetted in my config
file.

I am building this with VS 2008 and the 3.5 framework, but am not using or
referencing any assemblies that are specific to 3.5 - just a very basic
class library project.

I DO have all the prior versions of the framework installed (including the
one I'm targetting in my config file).

What do you think?
I think you've neglected to give us the most important bit of information
needed to diagnose the problem, which is the actual configuration file.

As far as I know you can't target specific frameworks at all. You can only
target specific runtimes, which is not the same thing. A runtime version is
something along the lines of "v2.0.50727" for .NET 2.0.

Under normal circumstances, it simply isn't necessary to specify a runtime
version. This should only be used if your application has compatibility
issues that prevent it from being run by a later runtime than the one it was
written for. If you're using VS 2008, you cannot be developing a .NET 1.x
application, so this probably doesn't apply.

If you want to ensure your 3.5 or 3.0 application will run on a 2.0
configuration, simply remove any references to 3.0 or 3.5 assemblies. The
runtime is the same for the 2.0, 3.0 and 3.5 frameworks. Well, almost --
..NET 3.5 will install the 2.0 SP1 runtime, but this is different only in
build number.
 
S

Scott M.

Jeroen Mostert said:
I think you've neglected to give us the most important bit of information
needed to diagnose the problem, which is the actual configuration file.

As far as I know you can't target specific frameworks at all. You can only
target specific runtimes, which is not the same thing. A runtime version
is something along the lines of "v2.0.50727" for .NET 2.0.

<startup>
<requiredRuntime version="2.0.50727" safemode="true" />
Under normal circumstances, it simply isn't necessary to specify a runtime
version. This should only be used if your application has compatibility
issues that prevent it from being run by a later runtime than the one it
was written for. If you're using VS 2008, you cannot be developing a .NET
1.x application, so this probably doesn't apply.

If you want to ensure your 3.5 or 3.0 application will run on a 2.0
configuration, simply remove any references to 3.0 or 3.5 assemblies. The
runtime is the same for the 2.0, 3.0 and 3.5 frameworks. Well, almost --
.NET 3.5 will install the 2.0 SP1 runtime, but this is different only in
build number.

I understand, but I need to be able to demonstrate the behavior nonetheless.
 
J

Jeroen Mostert

Scott said:
<startup>
<requiredRuntime version="2.0.50727" safemode="true" />
</startup>
That's wrong in two ways: only 1.0 applications should use
<requiredRuntime>, later versions must use <supportedRuntime>. Second, the
version number (name, actually) has to match a directory name in
%WINDIR%\Microsoft.NET\Framework *exactly*. So make it

<startup>
<supportedRuntime version="v2.0.50727" />
</startup>
 
S

Scott M.

Ok thanks. I was actually using the code from Professional Visual Basic
2008, page 968-969 and they show it with those two incorrect items.

Is there a way to verify the runtime version that is currently running the
assembly? Something in System.Reflection?
 
J

Jeroen Mostert

Scott said:
Ok thanks. I was actually using the code from Professional Visual Basic
2008, page 968-969 and they show it with those two incorrect items.
Tut tut. Well, I guess it shows that you can't believe everything you
read... Though that's still quite disappointing. It would have been a simple
matter for the authors to verify. I'll put this book on my list of books to
look into. There are some bad ones out there and I'd like to know what not
to recommend.
Is there a way to verify the runtime version that is currently running the
assembly? Something in System.Reflection?
System.Environment.Version.

But for heaven's sake, don't use this for anything more than informative
purposes (logging and error reports and such). Using this to check
compatibility is a very bad idea. If your assembly runs, you should, well,
run with it.
 

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