Reputation: 15217
Just out of interest, if I built some code using the Enumerable.Distinct function which appeared in .Net 3.5 and then ran it on a machine with .Net 2.0 on it, what would happen?
Upvotes: 3
Views: 143
Reputation: 292645
The program will crash as soon as the assembly that defines Enumerable.Distinct
(System.Core) is needed. However, you can make it work if you target .NET 2.0 and use LinqBridge instead of System.Core.
Upvotes: 5
Reputation: 17556
Simple,It will crash at aribitary points at where you used the .net 3.5 specific functionality.
But basic question ... why do you want to do that ?
If you have migrated a project from .net freamework version 2.0 to 3.5 and not using any feature of .net 3.5 does not represent a valid framework migration
Upvotes: 1
Reputation: 48587
You will be able to compile a 3.5 Framework project and run it on the 2.0 Framework as long as you don't have any 3.5 Framework references. In your case, you are using Enumerable.Distinct
which is in the 3.5 Framework references, so your application will fail.
Upvotes: 3
Reputation: 4134
Most probably your code will complain about .net 3.5 being not installed at the startup.
Upvotes: 1
Reputation: 391604
.NET 3.5 is essentially .NET 2.0 + some extra assemblies.
If those extra assemblies aren't installed, ie. .NET 3.5 isn't installed, then your program will fail to load those assemblies when needed.
If you have somehow managed to steer clear of using those assemblies, then presumably your program will function just fine, but I'd say that would be the exception to the rule. For your specific example, at the point where your program uses .NET 3.5 code for the first time, you would get an exception.
In short, make sure .NET 3.5 (SP1) is installed on the target machines.
Upvotes: 2
Reputation: 1184
.Net 2.0 won't understand the command because the library isn't there.
Upvotes: 2