While double clicking the pas file to open it in Delphi XE4 IDE, I am getting this error:
XML Parse Error:
Reason: The system cannot locate the object specified
This file uses xmldom, XMLIntf, oxmldom, XMLDoc units in its uses clause. I have changed nothing in this file and this opens up with no error in Delphi 7, but in Delphi XE4, its throwing above error when I double click .pas file to open it in IDE. After pressing OK, the .dfm file opens up.
Opening the .pas and .dfm files does not involve XML parsing. The fact that your unit uses some XML related units also does not involve parsing of XML at unit load time.
So this sounds like the IDE has a problem opening some auxiliary file associated with the source file. And something about this file or its reference in the source has not survived the transition from XE4. Look for files with the same stem as the troublesome source unit, but a different extension. Or look for IDE generated {...} comments in the source unit that refer to auxiliary files. This should hopefully lead you to a solution.
Related
I have an older DOS BP7 app with several program .pas files that are built. In Delphi it looks like I have to create a project to compile a .pas file, however it appears Delphi creates the program in the project file itself and references the .pas file that contains the older program and wants it to be a unit.
It looks like what I'd have to do is convert every .pas file to be a unit, copy over the begin / end from the .pas and place it in the .dpr file or make the program entry point a function or procedure and call that from the .dpr file?
Is there a more direct way to do this so that the .pas file doesn't need to be modified from a program to a unit and so I don't have to create a project for every program?
I have all the files needed to open the unit and code but I can't make any changes or compile because the Project.dproj and Project.dpr files are missing. However, I have the .exe file. Is there any way by which the aforementioned files can be extracted from the .exe file?
If you have all of the source files, meaning the .pas and .dfm files, then the first thing I'd do is add them all into a new project and try to compile it. It'll either work, meaning you've got everything you need, or it will generate errors.
There would be three kinds of errors:
The first is the most likely -- the forms might use components that you don't have installed. This will be obivous if you try to open the forms in the IDE. If they open without fanfare, GREAT! If you get a warning box saying "Cannot locate component: remove references to it?" or something like that, then you're probably hosed.
The second is version-specific errors -- stuff that's old and crufty and no longer supported by the language.
Third, the program may use run-time libraries that you don't have.
The compiler adds RTTI metadata, including unit names, when it builds, and if you know about how the RTTI tables are laid out it's possible to extract this. The unit list is the principal component of the DPR file, but it takes some serious work to access it and I'm not aware of any tools out there that read the RTTI tables that have been kept up to date beyond the Delphi 7 era.
As for the .dproj file, you're out of luck. That doesn't actually contain any code that gets "compiled in" to the EXE; it's a set of build instructions for how to produce the EXE. But if the Delphi IDE doesn't have one, it can generate a default .dproj from the .dpr, if you can produce that.
I'm curious, though. How did you obtain the .pas files but not the .dpr?
I wrote a test project which exposes a COM factory and object. Having tested and found our implementation to be working - i now want to move the code + typelibrary into our main project.
I copied the RIDL + TLB file into the main-project folder. I renamed both files accordingly (to the main project name). I also deleted the project resource file just in case Delphi places the TLB data here. And naturally i deleted the old TLB and RIDL files (I also deleted all DCU files, just in case). Last, I added the RIDL file to the main project and compiled.
The RIDL file is picked up by Delphi during compilation, it generates the TLB file as expected, but somehow it doesnt inject the TLB data into the exefile. So when i start the application i simply get an error message "Unable to load typelibrary". In my code i automatically create the COM factory on startup and update the windows registry. On shutdown the reverse happens.
Having fiddled with the typelibrary editor for hours, trying to register the typelibrary/exe from both Delphi and shell/regsvr32, delphi for some magical reason picked up the new file and everything worked as expected.
Problem is, I have no idea "why" it didnt work to begin with, nor do i know why it worked after hours of trying different combinations. So I am unable to reproduce the success. When updating our codebase I had to do the same on another computer/revision -- but this time it refused to work.
How can I force Delphi to inject the typelibrary?
Is there some "trick" (except the obvious like refreshing the RIDL, which generates the unit correctly but doesnt do anything about the TLB resource problem).
As I understand it the steps are as follows:
Add the .ridl file to the project. This will result in the build process compiling it to a .tlb file.
Link the .tlb resource with a $R conditional directive like this: {$R MyProject.tlb}
While opening a dfm file by double clicking, I am getting following error:
Class TMyClass not found. Ignore the error and continue? Note: Ignoring the error may cause components to be deleted or property values to be lost.
When I click Cancel, I get following message
Error creating form: Class TMyClass not found.
When I click OK now, pas file is opened only.
In pas file MyClass unit is added (which conatins the TMyClass defination) and its path is also added in my search path (Ctrl clicking on unit name, takes me to the unit file)
Everything is fine as per me. I don't know why I am getting this error and why am I not able to open this dfm file in RAD studio? Please help.
To create the component (that you placed on the form) Delphi IDE should know it by name and have its class loaded into memory. That means - it should have that component compiled into binary runtime package and that corresponding design-time package should be loaded into IDE and during the loading it should call RegisterComponent.
Usually this all is done during the library installation. So if you have that library for Delphi 7 now just install it for Delphi XE4 as well.
If your library does not have installer or that installer does not know XE4, then you have to register those components manually, just like Delphi documentations asks you to do.
That is a multi-step process, so you maybe would need to re-do it from starters. However with any luck you would probably be able to reuse the work already done for Delphi 7. At best case you only would have to recompile runtime and designtime packages in XE4 and then install those design-time ones into newer IDE.
http://www.cryer.co.uk/brian/delphi/error_class_not_found.htm
How to install a component from .pas file in delphi?
Delphi XE2: Encounter "Error Reading Form" when opening a project in IDE
Delphi XE4 "class not found" but compiles fine
http://docwiki.embarcadero.com/RADStudio/Rio/en/Installing_Component_Packages
http://delphi.about.com/library/howto/htinstallcomponent.htm
http://delphi.about.com/od/vclusing/ht/installwin32.htm
This problem occurred to me after a new version of Windows 10;
I adjusted by changing the permissions of my executable. I just removed the notification permissions and added it again;
https://support.microsoft.com/en-us/windows/change-notification-settings-in-windows-10-ddcbbcd4-0a02-f6e4-fe14-6766d850f294 for more details;
For me, this error happen when a visual control was declared as TSomething in the pas file and as TSomethingElse in the DFM file.
The solution was to manually edit the DFM file and put the control declaration to the correct value (TSomething).
I've received source code for a utility I want to adapt, but it appears to have the .dfm files stored in binary format, and one of the .dfm files seems to be coRruPted.
I also have the compiled .exe file.
Is there any way to extract the form from the .exe?
I can see from the relevant .pas file the form type declaration and the components on the form. How do I go about recreating the form from scratch, and 'attaching' it to the original .pas file?
Try using XN Resource Editor to recover the DFM from the .exe.