views:

560

answers:

1

It seems that when upgrading a project to .net 4.0 in VS 2010 Beta 2, a app.config file is generated, which roughly looks like this:

<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

Is this file needed in case I want to have a .NET 4.0 only executable? NOTE: Interestingly enough, this only happens in c# as opposed to f# projects.

I have successfully removed it without any visible (so far) side effects.

Can anyone elaborate on it's importance (if at all)

+4  A: 

It's not so much about how the app behaves on your computer, but how it will behave on other computers, or when you install an updated dotnet runtime on your machine.

Basically, if you don't include this, the latest version of the dotnet runtime will be used to run your app. That might sound like a good thing, until some feature that you depend on becomes deprecated or a bug that you don't realize you're depending on gets fixed.

More usefully, when you have originally built an app to work with an older version of the dotnet framework, you can use this feature after you've tested it with newer versions to assert that, yes, it does work with the latest version.

Here's the horse's mouth text from MSDN:

If the version of the .NET Framework that the application was built against is present on the computer, the application runs on that version.

If the version of the .NET Framework that the application was built against is not present and a configuration file does not specify a version in a Element, the application runs on the latest version of the .NET Framework that is present on the computer.

If the version of the .NET Framework that the application was built against is not present and the configuration file specifies a version in a Element, the application runs on the latest version that is specified in the application configuration file and is present on the computer.

JasonTrue

related questions