VS 2005 and .NET 3.0


G

G.S.

Could someone steer me in the right direction on setting up VS 2005
Pro to be able to create .NET 3.0 applications. And how to create 3.0
projects (Winforms, ASP.NET)
I've installed the
Visual Studio 2005 Extensions for Windows Workflow Foundation
but when I create a new project, I don't immediately see an option to
select what framework version it's based on.
Thanks!
 
Ad

Advertisements

M

Marc Gravell

I don't immediately see an option to
select what framework version it's based on.
Thanks!

There is no selector in 3.0; it just comes down to what references you
use. If you use the 3.0 dlls (System.ServiceModel, System.IdentityModel,
etc) then you have a 3.0 application; otherwise 2.0.

If you want it to be a bit slicker, you'll need to upgrade to VS2008.

Marc
 
G

G.S.

 > in 3.0
I meant in VS2005

Thank you!

Sory if that's not an accurate question, but what about C# laguagge
features that were introduced in 3.0?

I guess this all started when I tried to follow some code samples that
were not compiling... I thought they included 3.0 features, so I
wanted to crteated 3.0 Console App to run them...
Example:
struct MutableStruct
{
public int Value { get; set; }

public void SetValue(int newValue)
{
Value = newValue;
}
}

(this is from Jon Skeet's http://csharpindepth.com/Articles/Chapter8/PropertiesMatter.aspx)

Would a reference to 3.0's System namespace do it? I guess I'll try
Thanks!
 
G

G.S.

Thank you!

Sory if that's not an accurate question, but what about C# laguagge
features that were introduced in 3.0?

I guess this all started when I tried to follow some code samples that
were not compiling... I thought they included 3.0 features, so I
wanted to crteated 3.0 Console App to run them...
Example:
struct MutableStruct
{
    public int Value { get; set; }

    public void SetValue(int newValue)
    {
        Value = newValue;
    }

}

(this is from Jon Skeet'shttp://csharpindepth.com/Articles/Chapter8/PropertiesMatter.aspx)

Would a reference to 3.0's System namespace do it? I guess I'll try
Thanks!

Well, 2.0 is the only "System" dll that I can find...
I'd appreciate any light on the above "mistery" :)
 
R

Rory Becker

Hello G.S.,
Sory if that's not an accurate question, but what about C# laguagge
features that were introduced in 3.0?

AFAIK C# 3.0 is only available with .Net 3.5 (either the framework SDK or
VS2008).

You cannot use C#3.0 language features with VS2005
 
Ad

Advertisements

G

G.S.

Erm sorry Marc, not sure why I attributed that quote to you

Thank you both!

So to recap:

.NET Framework 3.0 uses the same version of the C# language as .NET
Framework 2.0
Then .NET Framework 3.5 introduces C#3.0

VS 2005 is hard-wired to use the .NET Framework 2.0 compiler and
there's no switch to flip to use .NET 3.5 compiler.

However, I could install .NET Framework 3.5 SDK and, I guess, manually
compile?
 
G

G.S.

First 3.0 and 3.5 is basically 2.0 with new capabilities brought into new
assemblies. In particular a 3.0 or 3.5 application stills runs with a 2.0
Common Language Runtime... So there is no 3.0 or  3.5 System.dll.

Then most of the new language features are compiler enhancements so :
- you need to use VS 2008 to use the new compiler
- even if you target 2.0 alone, you can still use most of those new language
features as they are just compiler tricks i.e. the generated code is the
same than previously, it's just the compiler that does a bit more work for
you with those new syntactic additions...


Thanks Patrice. I guess I was typing while you posted your comments.
 
M

Marc Gravell

I'm familiar with the book ;-p

No; VS2005 can only use the C# 2 compiler. VS2008 only uses the C# 3
compiler. However, you can use the 3.5 version of MSBuild (or csc) at
the command line to compile the code.

There is a big difference between the *language* C# 3 vs C# 2, and the
framework (1.1 / 2.0 / 3.0 / 3.5), and the runtime (1.1 / 2.0).

In this case, Jon is using C# 3 language features, so you cannot use
VS2005; or: you need to change it to C# 2, which isn't huge:

struct MutableStruct
{
private int _value; // _ to avoid confusion with
// value contextual keyword
public int Value {
get { return _value; }
set { _value = value; }
}

public void SetValue(int newValue)
{
Value = newValue;
}
}

Marc
 
M

Marc Gravell

AFAIK C# 3.0 is only available with .Net 3.5 (either the framework SDK
or VS2008).
You cannot use C#3.0 language features with VS2005

Actually, I believe the compiler is part of the core framework install,
not the SDK. And to clarify: the 3.5 here only refers to the compiler:
code built with the new compiler will work fine on 2.0 machines, as long
as the code doesn't *also* happen to use .NET 3.5 libraries.

Personally, I find it easier just to think of "the C# 3 compiler",
rather than the fact that it happens to ship with .NET 3.5.

Correct: you cannot use C# 3 language features with VS2005 in any useful
way.

Marc
 
Ad

Advertisements


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