Rookie build and deployment a dynamic library question - c#

I had a request to write a dll library using C#, it should be build under .NET 3.5.
I've build the library (it's a simple TCP client) using Visual Studio 2005 with .NET 2.0.50727.
I'm assuming that I can not deliver this library since it's built against wrong .net
I have more .NET versions installed on my development machine but it looks like I can't switch the .net in properties like JDK versions in eclipse for a particular project.
Is the only proper way of doing this is installing Visual Studio 2008 Express with 3.5 .NET?
Or some C# sdk with appropriate compiler (the thing is that I don't know the syntax for the c# compiler and NANT would be pain in the ass at this stage)?
cheers
P.

As jgauffin already mentioned your .Net 2.0 assembly will work fine in .Net 3.5.
And switching to another .Net Framework is just downwards possible.
So with VS2010 you can built against .Net 4, 3.5, 2.0 and 1.1
With VS2008 you can built against .Net 3.5, 2.0 and 1.1
With VS2005 you can built only against .Net 2.0
With VS2003 you can built only against .Net 1.1
So if you really need it just go and download it from here.

3.5 is just 2.0 with additional libraries. Your DLL will work fine from a .Net 3.5 application.
I might be wrong, but I think that 3.5 was introduced with Visual Studio 2008 and cannot be built against with 2005. That's why you can't switch version.

Related

VS 2012/2013 and .NET 4.5 Query

I am planning to install VS 2012 or 2013 and I was wondering if .NET 4.5 will get installed with it? I think it will but then what will happen to all my apps with target platform 4.0?
So my question is when I install VS, will my old apps which have target platform 4 contain elements of .NET 4.5?
Let say as example type string in 4.5 it has some improvements or something which 4.0 doesnt have. Will I get them even though I build against 4.0 according to target platform?
I would like to avoid some strange behavior in already existing projects just because I am running now visual studio 2013.
Any experience on this one guys?
Sorry in case of a duplicate question
In Visual Studio 2013 you can still build against .NET 4.0. The (highest) framework version installed on your development machine has no influence on the end result of your build process.
When installing .NET 4.5 in place of .NET 4 will change something on your PC: It gives you the ability to compile against the 4.5 version of the framework. As long as your compile your code against the NET 4.0 version, it has no need of .NET 4.5 to be installed.
If you target .NET 4.0, your code will not be able to access types which are specific to .NET 4.5 or .NET 4.5.1. However, your code will be running against .NET 4.5. That is only a problem if you do not test against .NET 4.0. In that case, you could find that bugs are fixed in .NET 4.5, but your users may still be using .NET 4.0, which may still have the bugs.

Visual Studio 2010's support for .NET 4.5

Having read numerous posts on the net and here at Stack Overflow about this I still am unsure as to whether VS 2010 supports .NET 4.5. MS states on http://www.microsoft.com/en-in/download/details.aspx?id=30653 that it is an in place upgrade .NET 4.
Does this mean that once .NET 4.5 has been installed on a machine with VS2010 installed I can still leave my target as .NET 4 but it will actually be using 4.5? For various reasons I cannot upgrade to VS 2012.
All pointers greatly appreciated.
You can't target .NET 4.5 with VS2010.
.NET 4.5 does not install side by side with .NET 4.0, it replaces it. But it still allows you to target .NET 4.0 with it installed, so it shouldn't break the installation AFAIK. But you can't utilize any of the .NET 4.5 features since you can't target anything higher than .NET 4.0 in Visual Studio 2010.
If you need to use these features, you will have to install Visual Studio 2012.

what .net version VS2005 use for C# project

I am porting a project built on VS2008 to VS2005 since the minor .NET version for us have to 2.0 instead of 3.5 and rest of our code is building on VS2005. So I modified the visual studio version from 2008 to 2005 at the .sln file
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
So I am able to load the .sln into the VS2005. I have some building problem, mainly the "var" and after I modified those lines with real data type, the code compiles and runs.
However at the project assembly reference. I found out that my code is still reference Linq which is from .NET 3.5:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Linq.dll
When I open up the dialog to add new reference, I could see that the .NET version 2.0, 3.5 and even 4.0 (although the CLR runtime version is 2.0.50727 in most of cases. sometimes 1.x and sometimes 4.0, Linq's runtime version is 2.0.50727).
I thought that VS2005 only supports .NET 2.0 which seems not that case here. So I guess how can I make sure that my application would only require .NET 2.0 framework. Is it enough to make sure that I only reference .NET 2.0 and below reference?
As long as the target framework is .NET 2.0 and you don't reference any libraries that do target higher .NET framework versions, your app should run just fine on .NET 2.0.
That said, I believe Visual Studio 2008 supports multi-targeting, so you should be able to use VS2008 but still target .NET 2.0 as your output type. Additionally, VS2010 and VS2012RC also support .NET 2.0 only projects.
To answer the exact question in the title (for the benifit of those who find this page by its title) the .NET version used by default in Visual Studio 2005 is .NET v2.0.
You can still use VS2008. VS2008 fully supports 2.0-only projects (just change the project settings). When in 2.0 mode VS will disable any 3.0 and 3.5 assemblies as well as any C# language features that depend on 3.0 or 3.5 library classes (such as extension methods, but there is a workaround to get those working with 2.0).
I'll say that VS2010 also supports 2.0-only projects too.

Can I use all C# 4.0 features in a project that targets .Net 3.5?

Development Environment :
- VS2010
- .Net Framework 4.0, 3.5, 2.0
Staging and Production Environments:
- .Net Framework 3.5, 2.0
The project I'm working on is targeting .Net Framework 3.5. And today I used optional parameters feature, which is new to C#4, in this project and it worked fine. I think VS2010 is using C#4 compiler and is compiling the method with optional parameters to corresponding overloaded methods in IL.
I want to know if I can use all new C#4 features as well.
You cannot use is the dynamic feature. This relies on the C# runtime and DLR DLL's which are only available on the 4.0 version of the .Net framework. Versions of the DLR are available for 3.5 but I do not believe they are compatible with the one required by the C# compiler.
Additionally you cannot use NoPIA / Embedded Interop Types in a down targetted scenario. This feature requires CLR support that was added in 4.0.
What's great about down targeting in Visual Studio 2010 though is you don't have to be aware of every limitation. If your projects are set to down target 3.5 and you use an incompatible feature, Visual Studio will produce an error.
I bumped into this a couple of weeks ago actually. I used optional parameters even though the project targeted .net 3.5. You need to be very careful of this because if you install the application on a computer that only has .net 3.5 runtime installed then your program may not run. In my case, I used the optional params and the nightly build server only had 3.5 installed so the build failed.

should i use Microsoft Visual C# 2010 Express to create a .Net 3.5 targeted, WPF Application?

i want to use Visual C# 2010 Express to create a .Net Framework 3.5 using WPF Application- this is due to the comfort that 2010 version gives to its user... (me)
So should I use version 2010 to create a WPF Application in .Net Framework 3.5? if yes, than how do i do that?
Thanks,
Din
You can target a previous version of the .NET Framework in Visual Studio 2010 (and 2008), for more info, see the MSDN How To article.
Creating your assembly like this is just fine, if you are not yet comfortable working the the new .Net revision. You can always retarget to .Net 4.0 later if you want to, and rewrite any code that could benefit from new additions to the Framework or language.
In corporate environments, it's not uncommon for older versions of .Net to be the desktop standard, and in that case you would have to target the specific version of the framework.

Categories