开发者

c# What happens if I use code a .NET 3.5 function on a machine that has .Net 2 installed

开发者 https://www.devze.com 2023-02-05 16:44 出处:网络
Just out of interest, if I built some code using the E开发者_StackOverflow社区numerable.Distinct function which appeared in .Net 3.5 and then ran it on a machine with .Net 2.0 on it, what would happen

Just out of interest, if I built some code using the E开发者_StackOverflow社区numerable.Distinct function which appeared in .Net 3.5 and then ran it on a machine with .Net 2.0 on it, what would happen?


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.


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.


.Net 2.0 won't understand the command because the library isn't there.


.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.


Most probably your code will complain about .net 3.5 being not installed at the startup.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消