Error opening a dfm file - Class xxxx not found - delphi

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).

Related

Prevent Delphi 10.2 from auto adding properties to TForm

I have a codebase that I'm working on that is written to work in both Delphi 5 and Delphi 10.2, until we get everything converted to D10.
Whenever I open a DFM file in 10.2 and save it, it automatically adds a DesignSize property to the TForm. This property doesn't exist in D5, so I get errors every time I open the same DFM in D5.
Is there any way to prevent D10 from auto-updating the DFM? Or is this not possible?
You could clear them out using a utility when needed. The JVCL includes a utility called DFM Cleaner that does this. In ends up in $(JVCL)\DevTools after JVCL is installed.
DFMCleaner is a tool to remove unsupported properties from DFMs. If
you save a dfm file in one version of Delphi and want to use it in an
earlier version, chances are there are some unsupported properties in
it, generating an error when the form is opened in Delphi. What's even
worse, if the dfm is part of a design-time package, Delphi will
install the package without errors but when you try to access the form
at design-time (f ex if the form is used by a property editor), Delphi
generates an AV instead.

Delphi XE6 - Access Violation at address 5006677D in module 'trl200.bpl'

I just upgraded to Delphi XE6. Everything went fine.
I installed a custom .bpl file and now when I try to load Delphi XE6 i get an error.
Access Violation at address 5006677D in module 'trl200.bpl'
I suspect it is because I forgot to recompile my component package before installing it on XE6.
Does anyone know where I can look to tell XE6 not to try to load this?
Just delete the bpl you tried to install (or rename it as suggested below). After a restart of Delphi you will be asked if you want to load the bpl next time Delphi is started, just press "no". Now try to install the bpl again, but then compiled for XE6. Do not delete rtl200.bpl! I have done so many times and never had to change the registry.

Delphi XE4 "class not found" but compiles fine

The GUI for my company's main product was written in Delphi in the late '90's, and has been updated to Delphi 2007. I'm working with a group to update the Delphi 2007 to XE4.
We still use a number of components from ADL VCL (similar to DevExpress, but now defunct), but have not installed the entire package. Rather, we have the files we need located in a folder seperate from our project folder, and have the path to these files specified in:
Tools-Options-Library-browsing path
and
Project-Options-search path
When I open main, I get the error:
"TADLAboutBox not found. Ignore the error and continue?"
The unit "ADLAbout" that defines "ADLAboutBox" is declared in the uses clause in main.
Moreover, our project compiles just fine.
How can I get rid of these messages? What might be wrong?
Thanks very much for your advice.
The component is not installed in the IDE, so when you open a form that uses that component you get an error.
But the source to the component can be found so when you compile it will do that without problems.
To get rid of the error you must install the component in the IDE.
ADL VCL is not available for XE4, since it was discontinued some time before XE4 was released. If you have the ADL source code, and have ported it to XE4, then it's plausible that you may have some success.
The error message you describe is symptomatic of not having the design-time packages for the components installed. You'll need to build and install design-time packages for any components that you want to interact with at design-time.

Message 'ToolsAPI not found' in a Form

In a package, I have a component which implements the ToolAPi IOTAIDENotifier Interface. The package can be setup, compiled and appears on the palette. A method of this component is designed to do something particular when a project, which uses it, is compiled (and not executed)...so far everything if OK.
The problem appears later, when I use this component on a TForm which belongs to another project.
When I try to build it, I get the compiler message File not found: ToolsAPI.dcu.
Here are the uses of the package:
Uses
{$IFDEF PACKAGESETUP} DesignIntf, DesignEditors,{$ENDIF}
Classes, ToolsAPI;
PACKAGESETUP is only defined when I compile the bpl
When I double click the error message, the IDE opens the file from which is declared the reference to ToolsAPI...How can I get rid of this problem ?
ToolsAPI is only available in designtime packages. It exists to expose the IDE for customisation and so is available only under the IDE, i.e. in designtime packages. You will have to remove the reference to ToolsAPI from your desktop app.

Why Delphi says "Unit xxx compiled with a different version of yyy" if all my paths are correct?

First of all I would like to apologize for the question itself. I simply could not make anything better. Well, the question then follows with examples and detailed ...
I manually installed QuickReport Delphi 2006 from their sources. It is composed of two packages a "DesignTime" and a "RunTime".
My Delphi is configured to build the BPL files in "D:\BPL" and DCP files on "D:\DCP" for all packages compiled on my Delphi
The source code of QuickReport are in "D:\QuickReport" and their packages (design and runtime) are configured to save the compiled units (DCU) in the folder "D:\QuickReport\DCU." This was the only configuration done in the packages. Nothing is set up with different paths and, BPL and DCP files are placed correctly in the folders I've set up, as I mentioned earlier.
With these settings I was able to build and install QuickReport without problems (just a few compiler warnings, which I believe are normal). All QuickReport components appear in your palette in Delphi, which does not emit any error on start proving that the components are properly installed and all packages were found.
Now comes the test: I started a new win32 application, completely empty, just a blank form. Then it put a QuickReport component (TQuickRep). The first thing I noticed was that the unit "QuickRpt", which is automatically placed in the clause "uses" of the "interface" is underlined in red indicating that something is wrong.
When I perform a CTRL+ENTER in "QuickRpt" unit (uses clause), the Delphi finds the source file (.pas) correctly, which is in "D:\QuickReport" then I ran a BUILD ALL command and the following compilation error appeared:
[Pascal Fatal Error] Unit1.pas (7): F2051 Unit QuickRpt was compiled with a different version of QRExpr.TQREvElement
That's it!!!
This error is only happening with Quick Report. I have other third-party components installed using the same configuration as the paths and they all work properly.
Finally I was able to solve this problem. #RRUZ and another friend gave me the tip: An lost QuickRpt.dcu file on my system. There were a QuickRpt.res file also. I found them, but the place was very improbable to me: The delphi LIB folder!!!
Well, i have some clues about this bizarre thing.
Until Delphi 7, the QuickReport was shipped together with the IDE however, it was disabled by default. On that Delphi version, all we need to do is to register the bpl to gain full access to QuickReport!
On Delphi 2006, the QuickReport is not part of IDE and there are no BPL to register, however the guys at Borland forgotten to remove all files from the old QuickReport. The Delphi Lib Folder is one of the first folders to be checked on Delphi start, so, if there are old files there, new files on another place would be never compiled, generating the annoying error!
This problem may be present on Delphi 2005 too.

Resources