问题描述
我已经接管了一个项目,该项目包含很多旧代码,包括C ++和C#,目前在VS 2010下(在Windows 7上)进行编译.
I've taken over a project with a lot of legacy code, both C++ and C#, currently compiling under VS 2010 (on windows 7).
当我构建解决方案时,令人惊讶的是,成功构建了143个项目.但是,有大量警告提示.其中令人惊讶的数量是关于过时功能的警告.
When I built my solution, amazingly, 143 projects built successfully. However, there were a boat load of warnings. A surprising number of them were warning about obsolete functions.
warning CS0618: 'System.Runtime.InteropServices.UCOMIMoniker' is obsolete
warning CS0618: 'System.Runtime.InteropServices.UCOMIEnumMoniker' is obsolete
warning CS0618: 'System.Runtime.InteropServices.UCOMIRunningObjectTable' is obsolete
warning CS0618: 'System.Runtime.InteropServices.UCOMIRunningObjectTable' is obsolete
warning CS0618: 'System.Runtime.InteropServices.UCOMIBindCtx' is obsolete
warning CS0618: 'System.IO.Path.InvalidPathChars' is obsolete
warning CS0618: 'System.Configuration.ConfigurationSettings.AppSettings' is obsolete
warning CS0618: 'System.Net.Dns.GetHostByName(string)' is obsolete
这是什么意思?这些函数显然仍处于定义状态,否则将无法编译,或者给我某种未找到"或未定义"的错误.缺少实现吗?这些功能是否仍然有效(和以前一样)?
What is meant by this? The functions are clearly still defined or they wouldn't compile or would give me some sort of 'not found' or 'not defined' error. Are the implementations missing? Do these functions still work (as well as they used to)?
我查了好几次,他们已经很久很久了.例如,GetHostByName:
Several I have looked up and they've been obsolete for a long long time. For example, GetHostByName :
.NET Framework
Supported in: 1.1
Obsolete (compiler warning) in 4.6
Obsolete (compiler warning) in 4.6
Obsolete (compiler warning) in 4.5
Obsolete (compiler warning) in 4.5.1
Obsolete (compiler warning) in 4.5.2
Obsolete (compiler warning) in 4
Obsolete (compiler warning) in 3.5
Obsolete (compiler warning) in 3.5 SP1
Obsolete (compiler warning) in 3.0
Obsolete (compiler warning) in 3.0 SP1
Obsolete (compiler warning) in 3.0 SP2
Obsolete (compiler warning) in 2.0
Obsolete (compiler warning) in 2.0 SP1
Obsolete (compiler warning) in 2.0 SP2
如果我理解这一权利,那么它在过去8-9年中已经过时(.NET 2.0于2006年问世).为什么没有人修复这些?是否需要修复?当我研究该GetHostByName方法时,将其替换为GetHostEntry.足够简单...但是,请耐心等待,很多人抱怨它与新功能无法正常工作,也许您应该改为调用GetHostAddresses来代替它.好吧,党.
If I understand that right, its been obsolete for the last 8-9 years(.NET 2.0 came out in 2006). Why hasn't anyone fixed these? Do they need to be fixed? When I researched that GetHostByName method, its replaced with GetHostEntry. Easy enough... but hold on, there are lots of people complaining that it doesn't work the same with the new function and maybe you should replace it with a call to GetHostAddresses instead. Well, dang.
鉴于我的解决方案中有超过28k个文件,所以我不确定我是否可以随意处理那些麻烦的事情.有没有办法知道过时的功能将支持多长时间?我应该期望这些在安装系统后甚至可以使用吗?使代码调用过时的接口(MSDN)会对系统产生什么影响?
Given that I've got over 28k files in my solution, I'm not sure I can just go messing with things willy nilly. Is there way to know how long obsolete functions will be supported for? Should I expect that these will even work once I get the system installed? What are the system implications of having code invoke obsolete interfaces (MSDN)?
我不是要了解如何从自己的系统中删除过时的代码,而是要系统如何处理外部系统(例如MSDN)上过时的接口.显然,它们并没有遵循标记为过时,替换和删除旧接口的简单循环.他们有什么政策? MSDN定义的接口的用户应如何应对过时的标记,尤其是当过时的代码没有被苹果对苹果"的等效功能代替时.
I am not trying to understand how to remove obsolete code from my own system, but how systems are supposed to deal with obsoleted interfaces on external systems (eg. MSDN). They clearly are not following a simple cycle of marking obsolete, replacing, and deleting old interfaces. What is their policy? How should users of MSDN defined interfaces react to the obsolete tag, particularly when the obsoleted code isn't replaced with an 'apples to apples' equivalent function.
推荐答案
通常,类或方法被标记为过时的,因为它们将在下一个版本中弃用,或者不再是执行特定任务的最有效方法.但是,Microsoft经常离开这些方法很长时间,以保证向后兼容.
Often classes or methods get marked as obsolete as they will be deprecated in the next release or are no longer the most efficient way to do a certain task. However, Microsoft often leaves these methods for a long time to guarantee backwards compatibility.
这篇关于过时的意思的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!