Delphi-修正VCL错误时,x单元是用x的不同版本编译的 [英] Delphi - Unit x was compiled with a different version of x, when fixing a VCL bug

查看:172
本文介绍了Delphi-修正VCL错误时,x单元是用x的不同版本编译的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在项目中使用的是Delphi XE6,并使用了Datasnap和JSON.我想在VCL单元System.JSON.pas(在TJSONString.ToString函数中)中纠正一个错误,该错误应转义反斜杠字符和引号.为了解决这个问题,我进行了以下操作:

I am using Delphi XE6 and using Datasnap and JSON in my project. There is a bug I want to correct in the VCL unit System.JSON.pas (in the TJSONString.ToString function) where it should be escaping backslash characters as well as quotes. In order to fix this I carried out the following :

  1. 从标准VCL源文件夹复制System.JSON.pas到我的项目源文件夹
  2. 将System.JSON.pas添加到我的项目中(使用新复制的文件)
  3. 修复了该错误并尝试进行编译

我收到错误消息"Unit Data.DBXCommon已使用其他版本的System.JSON.TJSONObject进行编译"

I get the error 'Unit Data.DBXCommon was compiled with a different version of System.JSON.TJSONObject'

我可以看到Data.DBXCommon单元引用了System.JSON,所以我猜编译器现在看到2个版本-我的固定版本和标准VCL版本.

I can see that the Data.DBXCommon unit references System.JSON, so I guess the compiler is now seeing 2 versions - my fixed version and the standard VCL version.

实施VCL更改以避免此问题的正确方法是什么?

What is the correct way to implement VCL changes to avoid this problem?

推荐答案

此问题有两个常见原因:

There are two common reasons for this issue:

  1. 您已更改了设备的界面部分.如果不重新编译使用要修改的单元的所有单元,就无法做到这一点.
  2. 您使用与最初构建单元时不同的编译器选项重新编译该单元.通过确保用于编译您修改的单元的编译器选项与Embarcadero所使用的相同,来解决此问题.通常,Embarcadero使用默认选项进行编译.将它们直接强加在要修改的源文件中,就在文件的最上方.

话虽如此,有关上述类似问题的此处最近的问题无法使用上述选项2解决.在该问题中,仅在XE6下,未经修改的Classes单元根本无法重新编译和链接.这让我想知道这种特殊技术是否已经存在.也许这甚至是不可能的.放弃之前,请查看是否可以编译和链接未修改的单元.

Having said this, a recent question here on a similar topic could not be resolved using option 2 above. In that question, under XE6 only, the unmodified Classes unit could not be re-compiled and linked at all. Which makes me wonder if this particular technique has had its day. Perhaps it's not even possible. Before you give up, see if you can compile and link the unmodified unit.

从更广泛的意义上讲,绕道行驶通常是解决您所面临的此类问题的简便方法.使用绕行而不是重新编译可以使修复程序的管理更加干净和简单.

More broadly, using a detour is generally an easier way to solve such problems as you face. Using a detour rather than re-compiling makes the management of the fix cleaner and simpler.

更新1

我无法获得未修改的System.JSON单元来重新编译和链接.我认为这意味着在另一个问题中提出的问题不仅限于Classes单元.我认为您会发现这是一个棘手的障碍,需要克服,建议您绕行.

I cannot get the unmodified System.JSON unit to re-compile and link. Which I think means that the issue raised in that other question is broader than just the Classes unit. I think you will find this a tricky hurdle to overcome and recommend the use of a detour.

更新2

似乎已在XE6中引入的问题,似乎已通过XE7的发行版得以解决.未经修改的System.JSON单元将在XE7中进行编译和链接.

The problem that appears to have been introduced in XE6, seems to have been resolved by the release of XE7. The unmodified System.JSON unit will compile and link in XE7.

这篇关于Delphi-修正VCL错误时,x单元是用x的不同版本编译的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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