Delphi 7至Delphi XE2 .res文件问题 [英] Delphi 7 to Delphi XE2 .res file issue

查看:211
本文介绍了Delphi 7至Delphi XE2 .res文件问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在Delphi XE2中打开Delphi 7项目并打开项目选项时,出现错误:

 设置图标:无法打开文件 ........ \AppName_Icon.ico。
系统找不到指定的文件。

我还注意到该项目的版本信息丢失了。
Delphi 7项目具有.Res文件,该文件具有MAINICON以及存储的版本信息。
为什么Delphi XE2无法使用此.Res文件检索MAINICON&版本信息。



此外,如果我尝试在XE2中编译应用程序,也会收到错误消息-

  [BRCC32错误] MtxReq.vrc(2):找不到文件:MtxReq_Icon.ico 

创建了MTXReq.vrc文件(一个新文件),并删除了MtxReq.res文件。



为什么会这样?我不想从.res文件中删除项目图标和版本设置。



有没有一种方法可以强制XE2使用.res文件而不是将其删除?



任何帮助将不胜感激。






对不起,我尚不能发表评论(需要更多的补充点)...



Warren -在这里回答您的问题(不会只是删除.dproj文件并仅保留.dpr,速度更快?)



我删除了.dproj,.dproj.local
打开了。 XE2中的dpr,并重新创建了.dproj文件。
它从.res中恢复图标,但是我丢失了项目版本信息。仅迁移了文件版本和产品版本信息,但丢失了所有其他版本信息。 (这是由于默认清单文件)。
然后我尝试了在解决方案的步骤1中解释的内容。
我在记事本中打开.dproj文件,删除了下面的标签条目,然后重新打开.dproj文件,现在我的所有版本信息都已恢复。这里的问题是$(BDS)\bin\default_app.manifest。
另外,我还注意到版本信息存储在.dproj文件中的标签下的标签中,并且一旦删除了默认的清单条目,IDE就会从.bp中正确地获取版本密钥信息。



因此,基本上,通过删除.dpr文件,我跳过了将.ico文件提取并添加到项目的步骤,但是不得不编辑新创建的.proj文件并删除默认清单的条目以进行检索版本信息。 (另一种解决方案是手动添加版本信息并保存项目。我没有尝试过)

解决方案

Update 2015 Remy手动手工重新创建.DPROJ文件的想法是极好的建议,即使我的回答被标记为接受,也应首先考虑。

XE2之前的Delphi版本在编译过程中将资源文件用作INPUT和OUTPUT。例如,您的delphi 7项目图标已嵌入到该.res文件中,您希望该文件使用delphi xe2,但是,这在delphi 7中是有问题的,现在在XE2中已无法解决。现在,您将.res文件视为纯输出工件,与可执行文件相同。不要再将.res文件检查到版本控制中了,也不要假装.res文件是您永久存储图标的地方。



如果您是一名现代开发人员,Delphi 7的旧工作方式可能会惹恼您(它肯定让我感到烦恼),因为您对版本控制该如何做有一个有趣且无法解决的问题:您是否签入.RES文件,还是不是?两种方法都有缺点,并且.RES文件现在仅在XE2中才是输出工件这一事实是最好的。因此,学会使用它。



现在,XE2不仅支持PC的图标,而且还支持Mac的图标,它必须以不同的方式处理事情,他们已经对此进行了清理。 。这就是您使用.ICO文件看到的问题的根源。我看到了完全相同的错误,而我却忽略了它,只是将图标转换成其他形式后再添加回该项目中。



转换delphi 7项目(.dpr和.cfg)到Delphi XE2的问题不像在各个级别的.dproj文件之间进行转换那样大-从Delphi 2005、2007、2009、2010开始的每个版本以及以后的版本都已对dproj格式进行了更改。当转换这些项目时出现问题时,我不会像雷米所建议的那样做,因为这是浪费时间。我要做的是删除DPROJ,只允许它从.dpr文件转换。

但是,雷米(Remy)从头开始的建议有很多优点,包括可以简化项目布局。



无论如何,这是您要做的事情


  1. 忽略错误。

  2. 添加图标来投影自己。

  3. 继续愉快地工作,不必担心会删除.res文件,这是有意的,并且有充分的理由。如有需要,将创建一个新的。磁盘上的.ico文件的文件名将使用XE2 .dproj文件的内容读取,并按原样编译到.res文件中。


When I open a Delphi 7 Project in Delphi XE2 and open the Project Option I get an error:

"Unable to set Icon: Cannot open file "........\AppName_Icon.ico".
The system cannot find the file specified".

I also notice that the Version info of the Project is missing. The Delphi 7 project has .Res file that has the MAINICON along with the version information stored. Why is Delphi XE2 not able to use this .Res file to retrive the MAINICON & Version information.

Also if I try to compile the application in XE2 I get an error -

[BRCC32 Error] MtxReq.vrc(2): file not found: MtxReq_Icon.ico

The MTXReq.vrc file (a new file) is created and the MtxReq.res file is deleted.

Why is this happening? I don't want to loose my project icon and version settings from .res file.

Is there a way to force XE2 to use the .res file and not delete it?

Any help will be greatly appreciated.


Sorry I can't post a comment yet (need more repotation points) ...

Warren - here the reponse to your question (Wouldn't just deleting your .dproj file and keeping the .dpr only, have been faster?)

I deleted the .dproj, .dproj.local Opened the .dpr in XE2 and it recreated the .dproj file. It brough back the icon from the .res but I lost project version info. Only File Version and Product Version info got migrated but lost all other versioning info. (This is because of the default manifest file). I then tried what I explained in Step 1 of my solution. I open the .dproj file in notepad deleted the tag entries under and reopened the .dproj file and all my version info now was recovered. The problem here is the $(BDS)\bin\default_app.manifest. Also I noticed that Version info is stored in tag under the tag in the .dproj file and once you delete the default manifest entries, the IDE pickups the version key information correctly from the .

So basically by deleting the .dpr file I skipped the step of extracting and adding the .ico file to the project, but had to edit the newly created .proj file and delete the entries for default manifest to retrieve the version info. (another solution would have been to manully add the version info and saving the project. I did not try this)

解决方案

Update 2015: Remy's idea of recreating .DPROJ files carefully by hand, is excellent advice and should be considered first, even though my answer is marked accepted.

Delphi versions prior to XE2 used resource files as an INPUT and an OUTPUT in the compilation process. For example, your delphi 7 project icon is embedded in that .res file, which you "want delphi xe2 to use", however, that's problematic in delphi 7, and now flat out impossible in XE2. Instead you now treat the .res file as a pure output artifact, the same as executable files. Don't bother checking .res files into version control any more, and don't try to pretend that the .res file is the place where you permanently store your icons. It's an output file produced automatically by the compiler, as it always should have been.

If you are a modern developer, the old way Delphi 7 worked might have annoyed you (it sure annoyed me) because you have the interesting and unsolveable question about what to do for version control: Do you check in the .RES file, or don't you? There were drawbacks to both approaches, and the fact that .RES files are now output artifacts only in XE2 is for the best. So learn to live with that.

Now that XE2 supports icons not only for a PC but also for a Mac, it must handle things differently, and they have cleaned this up. This is the origin of the problem you're seeing with the .ICO file. I have seen exactly the same error, and I have ignored it, and simply added the icon back to the project after it has otherwise been converted.

Converting a delphi 7 project (.dpr and .cfg) to Delphi XE2 is not as big a problem as the conversions between various levels of .dproj files -- each version starting with Delphi 2005,2007,2009,2010, and onwards has implemented changes in the dproj format. When problems occur with converting these projects, I do not do as Remy suggests, because it's a waste of time. What I do is DELETE the DPROJ and let it convert up from a .dpr file only.
But Remy's advice to start from scratch has many advantages, including that you may simplify your project layout.

Anyways, here's what you do:

  1. Ignore error.
  2. Add icon to project yourself.
  3. Continue merrily along, and don't worry about the deletion of the .res file, that's intentional, and for good reasons. A new one will be created whenever needed. The filename of the .ico file on disk will be read by using the contents of the XE2 .dproj file and compiled into the .res file, as it should be.

这篇关于Delphi 7至Delphi XE2 .res文件问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆