tags:

views:

1155

answers:

8

I write my app in VS 2008 and so use all the fanciful stuffs such as LINQ, object initializers etc. Now can my app run on machines that have only .Net 2.0 runtime, but no .Net 3.5 runtime? .Net 3.5 runtime is a huge download, as all of you might know.

A: 

No, they can not.

Ian P
+3  A: 

You can run it on .NET 2.0 if you don't use .NET 3.5 libraries. See Visual Studio multi-targeting support You can use LinqBridge to use Linq queries on .NET 2.0

For details, see MSVS multi-targeting screencast by Daniel Moth on Channel9.

aku
A: 

In most cases probably not, whilst .Net 3.5 still excute with the .Net 2.0 CLR there are a lot of new libraries and functionality that you are very likely to use such as the code that defines the extension methods that will not be available to your clients that don't have .Net 3.5 installed.

You can use VS2008 to target .Net 2.0. I think it is a property on the Solution element.

http://en.wikipedia.org/wiki/Microsoft_.NET#Microsoft_.NET has a lot of information.

Kinlan
A: 

You need to install it .Net 3.5 if you want to use its features.

Valery
+8  A: 

What you can use is for example the var keyword, auto-getters and auto-setters, object initializers. I.e. syntactic sugar that is compiled to 2.0 code.

What you can't use is functionality that resides in .Net framework 3.0 and 3.5 library. For example LINQ.

You can try for yourself what you can and can't use by setting target platform in Visual Studio to .Net Framework 2.0. The compiler will complain when you use things from Framework 3.0 and 3.5.

You can use Extension Methods with a little trick: Creating this class to your project

namespace System.Runtime.CompilerServices
{
    public class ExtensionAttribute : Attribute { }
}

Extension Methods are actually also compiled to 2.0 code, but the compiler needs this class to be defined. Read about it here

Andreas H.R. Nilsson
+1  A: 

I would recommend looking at Smallest DotNet to find a smaller version of the framework when deploying application for Framework 3.0 and 3.5.

Diago
A: 

If cost is not a factor, you might consider runtime virtualization software such as VMWare ThinApp or Xenocode Postbuild, both of which allow .NET applications to run without having to install the .NET runtime.

A: 

This article from Jean-Baptiste Evain explains how you can use C# 3.0 and LINQ and targeting machines on which there is only .NET 2.0 runtime installed.

The idea is to use System.Core Mono implementation, which is licensed under the MIT/X11 license.

Note : This answer was first provided to a duplicated question.

Romain Verdier