Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run c# 3 app without .Net Framework installed?

This may seem like a dumb question, but can an app build with c# 3 (.Net Framework 3.5) be built and deployed to a machine that does not have the 3.5 framework installed? i.e. does bin deployment work for System.Core and other 3.5 dlls?

I would really like to build my app using lambdas, linq, Func etc. but my client is not allowed to install the 3.0 or 3.5 frameworks on their machines (they do have the 2.0 framework installed).

like image 707
Chris Conway Avatar asked Aug 31 '26 21:08

Chris Conway


1 Answers

You can use C# 3.0 and target .NET 2.0. The following C# 3.0 features work perfectly:

  • Implicitly typed local variables (var)
  • Anonymous types
  • Lambda expressions converted to delegates (although you won't have the Func/Action delegates - you can define these yourself though)
  • Collection initializers
  • Object initializers
  • Implicitly typed arrays
  • Partial methods
  • Automatic properties

Extension methods require an attribute from System.Core, but you can define your own one. Query expressions will work if the right methods are available to be called - so you can deploy LINQBridge and still have LINQ to Objects, for example.

Expression trees won't work at all, unfortunately.

See my article on .NET versions for more information.

Don't try to deploy bits of 3.0 or 3.5 on top of a 2.0 system.

like image 93
Jon Skeet Avatar answered Sep 04 '26 16:09

Jon Skeet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!