每隔几周,我就会碰到这一点:当在Delphi项目中对使用单元进行IDE操作时,它会破坏.dpr文件.
会发生什么,它重建使用列表,但错误的位置.
我想知道要避免哪种使用模式,所以我不会再次遇到这个错误.
我在许多Delphi版本中都出现过这种错误.我知道它至少存在于Delphi XE2(今天又发生在那里),XE,2007,2006和7.
受损的片段通常是这样构造的:
ususes Forms,.. LastUnitInUses in 'LastUnitInUses.pas'; R *.RES}
uses Forms,.. LastUnitInUses in 'LastUnitInUses.pas'; {R *.RES}
出错的示例文件:
program SysUtilsFormatTests; { Delphi DUnit Test Project ------------------------- This project contains the DUnit test framework and the GUI/Console test runners. Add "CONSOLE_TESTRUNNER" to the conditional defines entry in the project options to use the console test runner. Otherwise the GUI test runner will be used by default. } {$IFDEF CONSOLE_TESTRUNNER} {$APPTYPE CONSOLE} {$ENDIF} ususes Forms,TestFramework,GUITestRunner,TextTestRunner,SysUtilsFormatUnit in 'SysUtilsFormatUnit.pas'; R *.RES} begin Application.Initialize; if IsConsole then with TextTestRunner.RunRegisteredTests do Free else GUITestRunner.RunRegisteredTests; end.
更正的.dpr文件示例:
program SysUtilsFormatTests; { Delphi DUnit Test Project ------------------------- This project contains the DUnit test framework and the GUI/Console test runners. Add "CONSOLE_TESTRUNNER" to the conditional defines entry in the project options to use the console test runner. Otherwise the GUI test runner will be used by default. } {$IFDEF CONSOLE_TESTRUNNER} {$APPTYPE CONSOLE} {$ENDIF} uses Forms,SysUtilsFormatUnit in 'SysUtilsFormatUnit.pas'; {$R *.RES} begin Application.Initialize; if IsConsole then with TextTestRunner.RunRegisteredTests do Free else GUITestRunner.RunRegisteredTests; end.
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。