简体   繁体   English

将C#从.net 4.5.2重写为.net 2.0

[英]Rewriting C# from .net 4.5.2 to .net 2.0

I have written a few toy projects in C# using Visual Studio 2015 RC and the Winforms project template. 我已经使用Visual Studio 2015 RC和Winforms项目模板在C#中编写了一些玩具项目。 I am trying to get my employer to use these to improve on the current Excel docs that are being used and for another process that we don't currently have a tool for. 我试图让我的雇主使用这些来改进当前正在使用的Excel文档以及当前我们尚无工具的另一个过程。

The target machines are running Windows XP which only seems to support .Net 2.0 and I had chosen to use .Net 4.5.2, as a result the apps will not run. 目标计算机运行的Windows XP似乎仅支持.Net 2.0,而我选择使用.Net 4.5.2,因此应用程序将无法运行。 I have searched Google and stackoverflow, but the answers I can find only seem to reference scaling the .Net version up and not down. 我已经搜索了Google和stackoverflow,但是我能找到的答案似乎只不过是扩大.Net版本而不是缩小规模。

Is there a more simple way of "converting" the projects from v4 to v2 than needing to design the GUI's again etc? 将项目从v4转换到v2是否比需要再次设计GUI等更简单的方法?

What version of Visual Studio will the developers be using? 开发人员将使用哪个版本的Visual Studio? The same version as you or an older version? 您使用的是相同版本还是旧版本?

If the same version, it is easy to fix: Open the solution and look at the properties of all projects. 如果版本相同,则很容易修复:打开解决方案并查看所有项目的属性。 Reset the target framework to 2.0 on all projects and attempt to compile. 在所有项目上将目标框架重置为2.0并尝试进行编译。 Fix any errors, which will most likely be new features in .NET that 2.0 does not contain. 修复所有错误,这些错误很可能是2.0中不包含的.NET中的新功能。

Older version? 旧版本? You have more work, as there are syntax tweaks (syntactical sugar) in each version of C#. 您需要做更多的工作,因为每个C#版本中都有语法调整(语法糖)。 The fastest way is switch framework locally, fix any issues, and then open the code in the same version of Visual Studio they are using. 最快的方法是在本地切换框架,解决所有问题,然后在使用的同一版本的Visual Studio中打开代码。 You will then go through another fix cycle to remove newer syntax. 然后,您将经历另一个修复周期,以删除较新的语法。

A PITA? 皮塔饼? For sure, but not as bad as a friend of mine who inherited an ASP.NET web app where the source code left with the developer. 可以肯定的是,但还不如我的一位朋友继承他的ASP.NET Web应用程序那么糟糕,源代码留给了开发人员。 ;-) ;-)

As for redesigning GUI, I am not sure what the issue here is, unless you are using new GUI elements not available in .NET 2/4. 至于重新设计GUI,除非您使用的是.NET 2/4中不可用的新GUI元素,否则我不确定这里的问题是什么。 If so, you have to remove and use older counterparts. 如果是这样,则必须删除并使用较旧的副本。 But anything completely incompatible should be found when changing Framework versions. 但是,在更改Framework版本时,应该找到完全不兼容的任何内容。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM