简体   繁体   English

根据安装的Net Framework版本运行不同的代码

[英]Running different code depending on what Net Framework version is installed

如果安装了Net Framework 3.5,是否可以使用普通LINQ运行LINQ方法,但如果安装了4.0或更高版本,则使用PLINQ?

I don't think that's possible. 我不认为这是可能的。 Here are some alternatives: 以下是一些替代方案:

  • If it is at all an option it would be much simpler to require your users to upgrade to .NET 4.0. 如果它是一个选项,那么要求用户升级到.NET 4.0会简单得多。
  • If you can't require your users to upgrade you can spend a little more time improving the .NET 3.5 code so that you don't need to make a special .NET 4.0 version. 如果您不能要求您的用户升级,您可以花费更多时间来改进.NET 3.5代码,这样您就不需要制作特殊的.NET 4.0版本。
  • Or you can make two different builds of your project using #if directives. 或者,您可以使用#if指令制作项目的两个不同版本。

While i also don't think its wise to code two versions you can use the Environment.Version variable. 虽然我也不认为编写两个版本是明智的,但您可以使用Environment.Version变量。

It is there in all .net versions since 1.1 and Silverlight. 它存在于自1.1和Silverlight以来的所有.net版本中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 相同的方法,但不同的签名取决于.NET Framework版本? - Same method but different signature depending on .NET framework version? Target.NET 框架版本与安装的 .NET 框架版本 - Target.NET framework version vs .NET framework version installed ClickOnce:此计算机上未安装所需的.NET Framework版本 - ClickOnce: The required version of the .NET Framework is not installed on this computer 获取已安装的.NET框架版本的完整列表 - Get full list of .NET framework version installed 在不同的 Visual Studio 版本上运行相同的代码给出不同的输出(代码和框架保持不变) - Same code while running on different Visual Studio version gives different output(Code and framework remains unchanged) 在未安装 .Net 的 xp 上运行 .Net Framework 应用程序 - Running .Net Framework application on xp without .Net installed .NET - 我目前在哪个版本的框架中运行(来自C#) - .NET - what version of the framework am I currently running in (from C#) 在其他.net框架版本中执行方法 - Execute a method in a different .net framework version .NET Framework和CLR版本之间有什么区别 - What is the difference between .NET Framework and CLR Version 为什么具有相同目标框架版本的两个应用程序的.NET版本不同 - Why .NET version is different for two app with same target framework version
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM