none
Combining .NET framework versions RRS feed

  • Question

  • I have created an API (basically a .NET assembly), using C# in Visual Studio 2005. The clients of this API is using Visual Studio 2005 as well.

    My plan to upgrade to Visual Studio 2008 and .NET Framework 3.5. If I rebuild my .NET assembly with Visual Studio 2008 (and target .NET Framework 3.5), will the people who're using Visual Studio 2005 still be able to reference the assembly and call functions on it?

    I assume there would be problem if the assembly exposed .NET 3.x-specific functionality such as extension methods and linq-stuff?

    Thursday, June 25, 2009 2:32 PM

Answers

  • Yeah, your close.  Except that I can't think of any class that was available in 2.0 and got changed in 3.5.  Think of 3.0 and 3.5 as expansion packs instead of new versions.  They really should have numbered them 2.0A and 2.0B.  The next one, .NET 4.0 is a true new version.

    Hans Passant.
    • Proposed as answer by OmegaManModerator Friday, June 26, 2009 12:08 PM
    • Marked as answer by M. Knafve Friday, June 26, 2009 2:34 PM
    Friday, June 26, 2009 9:27 AM
    Moderator

All replies

  • There's a difference between "exposing" and "using".  But, yeah, exposing an extension method or a Linq class is going to cause trouble for a client that uses the C# 2.0 compiler.  You can upgrade your version of Visual Studio but you don't necessarily have to upgrade your public interfaces.

    Hans Passant.
    Thursday, June 25, 2009 2:43 PM
    Moderator
  • Or use VS2008 and keep the projects targetting .Net 2.0 and don't use the great new features of .Net 3.5.
    William Wegerson (www.OmegaCoder.Com)
    Thursday, June 25, 2009 3:05 PM
    Moderator
  • I'm a bit confused by the NET Framework-versioning. When I'm "targetting v.3.5", what really happens is that C# 3.0 compiler will be used in combination with assemblies from %WINDOWS%\Microsoft.NET\Framework\v3.5. The .NET runtime which actually executes the code later on will be the same (2.0). Correct?

    So let's say I have an API, targetting 3.5 with as single class with 3 functions:

    void Test1(int) {return null;}
    void Test2(System.Data.DataSet) {return null;}
    void Test3(DataContext) {return null;}

    As I understand it, a client targetting v2.0 (using VS2005)
    - will be able to instantiate this class and call Test1(). The VS2005 C# compiler recognizes void and int and will compile.
    - may be able to call Test2() if the version of System.Data in framework 2.0 is the same as in framework 3.5. If not, the compiler will complain that it cannot find the type System.Data.DataSet of the specific version used in the API.
    - will not be able to call Test3(), since "DataContext" isn't defined in any of the referenced assemblies (since it's in the 3.5 framework)

    Am I right here or am I on the wrong track?

    Friday, June 26, 2009 7:19 AM
  • Yeah, your close.  Except that I can't think of any class that was available in 2.0 and got changed in 3.5.  Think of 3.0 and 3.5 as expansion packs instead of new versions.  They really should have numbered them 2.0A and 2.0B.  The next one, .NET 4.0 is a true new version.

    Hans Passant.
    • Proposed as answer by OmegaManModerator Friday, June 26, 2009 12:08 PM
    • Marked as answer by M. Knafve Friday, June 26, 2009 2:34 PM
    Friday, June 26, 2009 9:27 AM
    Moderator
  • Hi,

    I have a doubts here,

    if Nitramafve compiles the (API)dll in 3.5 FW and supply this a consumer who is using 2.0 FW, will the consumer be able to run his application with out 3.x FW?

    I think what OmegaMan suggested would be a good way to go.

    Regards,
    Vinil
    Friday, June 26, 2009 2:26 PM
  • After my post I did run some tests which confirms what you're saying.

    Thanks for the replies.

    Friday, June 26, 2009 2:34 PM