Compiling a .NET 3.5 project and running on a .NET 2.0 machine

For those that are still curious after my previous post about using C# 3.0 features in .NET 2.0. You can compile any .NET Framework 3.5 project and run it in a .NET Framework 2.0 environment (read, no .NET Framework 3.5 installed) without any problems… as long as there are no dependencies to the .NET 3.5 assemblies!

Create a new Console Application under .NET Framework 3.5. Check your references, System.Core will be automatically added to the project. This is a .NET Framework 3.5 assembly. Remove it.

Now add a single Console.WriteLine as follows:

using System;

using System.Collections.Generic;

using System.Text;

 

namespace FrameWork35ConsoleApp

{

  class Program

  {

    static void Main(string[] args)

    {

      Console.WriteLine(“Hello world from a .NET 3.5 application.”);

    }

  }

}

Compile it and copy the executable to a .NET Framework 2.0 machine. Again, one without .NET Framework 3.5 installed.

Run the executable and watch the result.

You may also like...

1 Response

  1. Delf says:

    3.5 is based on 3.0 which is based on 2.0… try to use WCF in the console application and run it on framework 2.0… outch!

Click on a tab to select how you'd like to leave your comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.