Graviton
Graviton

Reputation: 83244

Can .Net 3.5 apps run on machines that have .Net 2.0 runtime installed?

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.

Upvotes: 3

Views: 3484

Answers (8)

Romain Verdier
Romain Verdier

Reputation: 12971

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.

Upvotes: 0

PoppaVein
PoppaVein

Reputation: 659

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.

Upvotes: 0

BinaryMisfit
BinaryMisfit

Reputation: 30499

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.

Upvotes: 1

andynil
andynil

Reputation: 29138

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

Upvotes: 9

aku
aku

Reputation: 123956

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.

Upvotes: 5

Valery
Valery

Reputation: 378

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

Upvotes: 0

Kinlan
Kinlan

Reputation: 16597

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.

Upvotes: 0

Ian P
Ian P

Reputation: 12993

No, they can not.

Upvotes: -3

Related Questions