473,322 Members | 1,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Targetting a class library for both 3.5 and 2.0

I have a rather big class library solution with lots of projects.

Some of these projects I'd like to include .NET 3.5 things in, but only
when I'm targetting 3.5.

Basically, I'd like to be able to target 3.5 and rebuild, getting new
things into the new dll's for 3.5, and also be able to target 2.0 and
rebuild, to get files for 2.0.

What is the best way to do this? The "best" way I've come up with so far
is to make a new solution file and new project files with a named
definition and use #if..#endif to make files, or just not include the
3.5 files in the 2.0 projects, but this seems like a rather big
maintenance nightmare.

I'd like to have one solution and all of the projects once, and include
files that may or may not produce any compiled code depending on the target.

Or am I way off target here? Any thoughts would be welcome.

--
Lasse Vågsæther Karlsen
mailto:la***@vkarlsen.no
Nov 20 '07 #1
8 1044

Can't you just #if/#endif wrap the entire class definitions within the
3.5-specific classes? I don't see the need for extra solution files
or separate projects.

The complicated parts will be when there are interdependencies and
making sure that a 2.0 tareted class does not reference a 3.5-only
class. You'll find this pretty quick with automated build of both
targets thought (continuous integration would be good here). However,
keeping 3.5 specific stuff to an entirely 3.5-specific project would
make this process even easier.

HTH,

Sam
------------------------------------------------------------
We're hiring! B-Line Medical is seeking .NET
Developers for exciting positions in medical product
development in MD/DC. Work with a variety of technologies
in a relaxed team environment. See ads on Dice.com.

On Tue, 20 Nov 2007 15:38:31 +0100, Lasse Vågsæther Karlsen
<la***@vkarlsen.nowrote:
>I have a rather big class library solution with lots of projects.

Some of these projects I'd like to include .NET 3.5 things in, but only
when I'm targetting 3.5.

Basically, I'd like to be able to target 3.5 and rebuild, getting new
things into the new dll's for 3.5, and also be able to target 2.0 and
rebuild, to get files for 2.0.

What is the best way to do this? The "best" way I've come up with so far
is to make a new solution file and new project files with a named
definition and use #if..#endif to make files, or just not include the
3.5 files in the 2.0 projects, but this seems like a rather big
maintenance nightmare.

I'd like to have one solution and all of the projects once, and include
files that may or may not produce any compiled code depending on the target.

Or am I way off target here? Any thoughts would be welcome.
Nov 20 '07 #2
Samuel R. Neff wrote:
Can't you just #if/#endif wrap the entire class definitions within the
3.5-specific classes? I don't see the need for extra solution files
or separate projects.
I guess that leads me to the next question, are there predefined define
names that are automatically set by 2.0 and 3.5? otherwise I'd need
project-settings for these?

ie.

#if <what goes here for 2.0 or 3.5?>

--
Lasse Vågsæther Karlsen
mailto:la***@vkarlsen.no
http://presentationmode.blogspot.com/
Nov 20 '07 #3
Lasse Vågsæther Karlsen <la***@vkarlsen.nowrote:
Samuel R. Neff wrote:
Can't you just #if/#endif wrap the entire class definitions within the
3.5-specific classes? I don't see the need for extra solution files
or separate projects.
I guess that leads me to the next question, are there predefined define
names that are automatically set by 2.0 and 3.5? otherwise I'd need
project-settings for these?

ie.

#if <what goes here for 2.0 or 3.5?>
They're not defined by the framework - they're defined by Visual Studio
(being compile-time only). However, I don't believe there are any
"standard" ones beyond TRACE and DEBUG.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Nov 20 '07 #4
Jon Skeet [C# MVP] wrote:
Lasse Vågsæther Karlsen <la***@vkarlsen.nowrote:
>Samuel R. Neff wrote:
>>Can't you just #if/#endif wrap the entire class definitions within the
3.5-specific classes? I don't see the need for extra solution files
or separate projects.
I guess that leads me to the next question, are there predefined define
names that are automatically set by 2.0 and 3.5? otherwise I'd need
project-settings for these?

ie.

#if <what goes here for 2.0 or 3.5?>

They're not defined by the framework - they're defined by Visual Studio
(being compile-time only). However, I don't believe there are any
"standard" ones beyond TRACE and DEBUG.
So basically I either have to make two project files, containing
different directives, or change them each time in the single project file?

--
Lasse Vågsæther Karlsen
mailto:la***@vkarlsen.no
http://presentationmode.blogspot.com/
Nov 20 '07 #5
Lasse Vågsæther Karlsen wrote:
Jon Skeet [C# MVP] wrote:
>Lasse Vågsæther Karlsen <la***@vkarlsen.nowrote:
>>Samuel R. Neff wrote:
Can't you just #if/#endif wrap the entire class definitions within the
3.5-specific classes? I don't see the need for extra solution files
or separate projects.
I guess that leads me to the next question, are there predefined
define names that are automatically set by 2.0 and 3.5? otherwise I'd
need project-settings for these?

ie.

#if <what goes here for 2.0 or 3.5?>

They're not defined by the framework - they're defined by Visual
Studio (being compile-time only). However, I don't believe there are
any "standard" ones beyond TRACE and DEBUG.

So basically I either have to make two project files, containing
different directives, or change them each time in the single project file?
I guess I'll make new projects for the 3.5 parts.

--
Lasse Vågsæther Karlsen
mailto:la***@vkarlsen.no
http://presentationmode.blogspot.com/
Nov 20 '07 #6
Lasse Vågsæther Karlsen <la***@vkarlsen.nowrote:
So basically I either have to make two project files, containing
different directives, or change them each time in the single project file?

I guess I'll make new projects for the 3.5 parts.
I think that's the only sensible way to go - because I don't believe
you can have conditional *references*, and you don't really want .NET
3.5 references in an assembly running in .NET 2.0, I suspect...

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Nov 20 '07 #7
Jon Skeet [C# MVP] wrote:
Lasse Vågsæther Karlsen <la***@vkarlsen.nowrote:
>>So basically I either have to make two project files, containing
different directives, or change them each time in the single project file?
I guess I'll make new projects for the 3.5 parts.

I think that's the only sensible way to go - because I don't believe
you can have conditional *references*, and you don't really want .NET
3.5 references in an assembly running in .NET 2.0, I suspect...
You're right.

Looks like I finally get to test out the branching capabilities of
Subversion I guess :)

I won't be doing much development in 2.0 mode from now, but bugfixes
will be present, so I think I'll just branch off for 2.0, and change
everything to 3.5 for the main trunk.

I've identified a lot I want to change for 3.5 anyway, to take advantage
of new features, and having #if...#endif everywhere will be hard to
maintain for long I think.

Thanks for the input.

--
Lasse Vågsæther Karlsen
mailto:la***@vkarlsen.no
http://presentationmode.blogspot.com/
Nov 21 '07 #8
On Nov 21, 11:48 am, Lasse Vågsæther Karlsen <la...@vkarlsen.no>
wrote:
I think that's the only sensible way to go - because I don't believe
you can have conditional *references*, and you don't really want .NET
3.5 references in an assembly running in .NET 2.0, I suspect...

You're right.

Looks like I finally get to test out the branching capabilities of
Subversion I guess :)
The good news is that Subversion branching support is wonderful :)
I won't be doing much development in 2.0 mode from now, but bugfixes
will be present, so I think I'll just branch off for 2.0, and change
everything to 3.5 for the main trunk.
That makes a lot of sense.

Jon
Nov 21 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: SevDer | last post by:
Hi I have a class library that needs to download the HTML in a specific page of ours with provided querystring. When I open this URL with any browser, it loads fine. When I do WebRequest from Web...
3
by: eBob.com | last post by:
I have several applications which mine web sites for personal information which they publish. They publish the info in one form, I transform the info into Excel spreadsheets. So all these...
3
by: ad | last post by:
I have a web application and a class library in a solution. The class library is make of typed datasets, and include many Table in it. The connection strings of the TableAdapters is come from...
1
by: Tony Johansson | last post by:
Hello!! I use VS 2003 and C#. I have sent several mail even tried with crossgroup because I want to find out if my problem is a bug in .NET or if .NET doesn't support what I do. It's only one...
5
by: tony | last post by:
Hello! This is a rather long mail but it's a very interesting one. I hope you read it. I have tried several times to get an answer to this mail but I have not get any answer saying something...
0
by: James MA | last post by:
I'm going to develop a common library for applications in both Windows and Windows Mobile, this library will contain the bussiness rule only, which only contain some simply mathematics, and it...
14
by: budy_ludy | last post by:
Hi All, I am new to vb .net, I have an ArrayList and i store class objects in it, and later i want to retrieve each ArrayList items and type cast to the class, How can it be done ? I used...
5
by: Rainer Queck | last post by:
Hello NG, Is it possible to share the settings of an application with a class libreary? In my case I have a application and a set of different reports (home made) put into a class library. The...
3
by: Med | last post by:
Hi, I use Visual C# Express 2005 and Visual Web Developer Express 2005. In my Visual C# Express 2005 Solution, I have following two class library projects: _ DataAccess (Namespace name:...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.