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 :
I get the error 'Unit Data.DBXCommon was compiled with a different version of System.JSON.TJSONObject'
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.
What is the correct way to implement VCL changes to avoid this problem?
There are two common reasons for this issue:
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.
Update 1
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.
Update 2
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.
Hi David, I don't think I'm using any modified compiler options. The note about XE6 could well be relevant. I successfully implemented my fix in XE2, I'm just migrating the project to XE6 and this is the only problem I've come across.
Thanks David, went with using a detour in the end using the code from here chee-yang.blogspot.co.uk/2008/11/hack-into-delphi-class.html. Not used this technique before but definitely prefer it to making copies of VCL source files.
The code for detouring in this answer is simpler still: stackoverflow.com/questions/8978177/…