- System.Xml and Delphi.net: validate and read xml file
- Printing with Delphi.net
- Make DUnit work on Mono. My goal was to have my tests written in Delphi, but testing both on Mono and Ms.net.
That meant I had to get rid of all Borland dependancies of DUnit.
I have modified these files: TestFramework.pas and TextTestRunner.pas. Some functionality is gone, because it was not important to me (e.g. inifiles).
See mytest.dpr and mytest.pas for examples how to use the DUnit classes.
- Create Charts in Excel from Delphi.net, using late binding.
Helpful articles were:
Enhance .NET applications with Excel charts from Tony Patton and
Binding for Office automation servers with Visual C# .NET from MSDN.
Here is my code: mytest.dpr and
excel.pas.
- Windows Message with Delphi.net:
Looking at an example like Keyboard event handling in .NET applications by Alfred Mirzagitov, using C#, we wondered how it works with Delphi.net, to process the wParam of a message etc. The above linked pascal file is the result of it.
- Make ODBC work on Linux with Progress and Postgresql and Mono
- We had the compiler error: "[Error] E2199 Packages 'dummy' and 'Package1' both contain unit 'Borland.Delphi.System'" when we wanted to create a hierarchy of packages referencing each other. Finally my colleague found the hint here
(search for "Common problems when recompiling":
Just delete all *.dcpil and *.dcuil files, and recompile again!
And it seems, a reference to Borland.Delphi.dll is just always required, at least in the top package/exe. Fortunately, if you install that in the Mono GAC, it works fine even on Linux.
Example for DOS, Mono command prompt:
Copy the Borland.Delphi.dll from the CD, e.g. copy D:\Install\GlobalAssemblyCache\Borland.Delphi.dll .
Or copy it from c:\windows\assembly\GAC\Borland.Delphi\
gacutil -i Borland.Delphi.dll
- Borland Delphi.net 2005 & Makefiles
- Mono on the Linux Server, Client on Windows, connecting with System.Runtime.Remoting; we got strange errors, e.g. "GetHostByName" etc. We finally found out, that we forgot to add the hostname to the hosts file on Windows. see also this mail on the mono-list
- Creating strongly typed dataset classes from xsd file:
Borland Delphi uses the Microsoft.net tool xsd.exe, and gives in a parameter to create the delphi files (all in one line):
"C:\Program Files\Microsoft.NET\SDK\v1.1\bin\xsd.exe"
/dataset
/language:"Borland.Delphi.DelphiCodeProvider,DelphiProvider, Version=9.0.1882.30496,
Culture=neutral, PublicKeyToken=91d62ebb5b0d1b1b"
/namespace:"MyDataSetUnit"
MyDataSet.xsd
- Initialisation of an array in Delphi: You can initialise an array in Delphi not only in the var section, but also in the code.
var mytest: array[] of String;
begin
mytest := new(array[] of String, ('test1', 'test2'));
end;
I got that from Nick's Delphi Blog: Array of String at Runtime.
Update: better "Delphi" Style:
type TMyStringArray = array[] of string;
var mytest: array[] of String;
begin
mytest := TMyStringArray.Create('test1', 'test2');
end;
- Regular Expressions with Delphi.net: System.Text.RegularExpressions, IsMatch, Split
- Looking at Server Side Sponsors, for Remoting, using the example "ServerSideSponsoring" from Chapter 7 of the Book
"Advanced .Net remoting", Rammer/Szpuszta
(code available on their website):
Mono gave exception:
System.Runtime.Remoting.RemotingException: Requested service not found.
No receiver for uri aafb3665_8b51_47e2_85d4_2b2d3483ed20/-855822568_4.rem
To solve that, change the times in ServerHost.exe.config:
For me it works:
<lifetime leaseTime="5S" renewOnCallTime="5S" leaseManagerPollTime = "5S" />
- problem with remoting dates in typed datasets, if the client and the server are in different timezones; this occurs on windows/windows and windows/mono situation;
Solution:
I have written my own version of GetSerializationData:
procedure TTypedDataSet.MyOwnGetSerializationData(
info: System.Runtime.Serialization.SerializationInfo;
context: System.Runtime.Serialization.StreamingContext);
var
reader: XmlTextReader;
strSchema, diffgram: System.String;
begin
strSchema := info.GetValue('XmlSchema', typeof(string)) as string;
diffGram := info.GetValue('XmlDiffGram', typeof(string)) as string;
// fix the dates; somehow there is a problem with the linux (also windows) server and windows client, when they are in different timezones:
// e.g. 4/28/1971 00:00:00 on the client becomes 4/27/1971 11:00:00 PM on the server
// replace the date values (time at midnight) with same value, but without timezone information
// that should also prevent a problem that occurs on mono and Redhat (http://bugzilla.ximian.com/show_bug.cgi?id=38824)
diffGram := Regex.Replace(diffGram, 'T00:00:00.0000000[+|-][0-9][0-9]:[0-9][0-9]<', '<');
reader := XmlTextReader.Create(StringReader.Create(strSchema));
ReadXmlSchema (reader);
reader.Close ();
reader := XmlTextReader.Create (StringReader.Create(diffGram));
ReadXml (reader, XmlReadMode.DiffGram);
reader.Close ();
end;
constructor TTypedDataSet.Create(info: System.Runtime.Serialization.SerializationInfo;
context: System.Runtime.Serialization.StreamingContext);
var
Relation: TTypedRelation;
ds: DataSet;
begin
inherited Create();
MyInitClass(true);
MyGetSerializationData(info, context);
MyInitVars();
MyInitConstraints();
EnforceConstraints := ds.EnforceConstraints;
MyEnableConstraints();
MyEnableRelations();
end;
- problem with mono Delphi.net Appdomain Remoting using MarshalByRefObject
- the situation: Program written in Delphi.net, running on Mono
- loads a DLL (does not matter whether in C# or Delphi.net) into an appdomain, the DLL has an Object derived from MarshalByRefObject.
- The constructor of the Object has parameters, that set member variables of the object
- When you call remotely a method of that object, the member variables are nil again.
- Something must be wrong with Delphi.net and Mono. it works fine on MS.net, and works fine if both programs are in C#
- solution: constructor should not have any parameters, use an extra function to initialise the member variables.
- problem with Multiselect Listbox and Checkedlistbox etc in Windows.Forms, when it is on a tabbed page: The selection is lost, when you switch forth and back.
described here as well: Common problem with bound controls on tab pages
solution: myTabPage.BindingContext = myForm.BindingContext
Perhaps you also need to bind the control itself, myLstControl.BindingContext = myForm.BindingContext
- Some words about the frustrations we have with the Borland Delphi.net IDE: With complex usage of inherited forms, and using user controls etc., the designer often fails to display the WYSIWYG representation of the form. You get messages like these:
The designer can not be shown because deserialization threw an exception, FieldAccessException, and many others more.
Several things might help: Delete all dcuil, dcpil, pdb and dll files, and rebuild everything; it also might help to not open the whole project group with all the dlls, but only the bdsproj file with your form in question. Build it again, and hopefully you can see the form.
Let's hope for a better Delphi.net IDE in the future!
- Another Borland Delphi.net 2006 IDE annoyance:
We suddenly get compiler errors like that:
[Pascal Fatal Error] E2213 Bad packaged unit format: System.Web.dcpil.System.Web
[Pascal Fatal Error] E2213 Bad packaged unit format: System.EnterpriseServices.dcpil.System.EnterpriseServices
The problem is that paths are automatically added to the search path of the project:
$(BDS)\lib\Debug\Indy10
$(BDS)\lib\Debug
c:\program files\common files\borland shared\bds\shared assemblies\4.0
solution:
rename C:\Program Files\Borland\BDS\4.0\lib\debug to debug2
Then it compiles again. very strange
- Problems installing JCL on Borland Delphi 2006
Error messages:
Borland Developer Studio 2006 Build 10.0.2288.42451
Compiling package C:\tmp\JVCL320\jcl\packages\d10\Jcl.dpk...
No personality supports the extension .dpk
Solution: I had to install Borland Delphi 32, my installation only had Delphi.net...
- windows\system32\drivers\etc\services file: somehow .net does not use this file for establishing TCP connections (e.g. System.Net.Sockets.TcpListener.Create(service)); there is the need to map the service name to a port number, using etc/services;
Here is the code for Delphi.net, that uses getservbyname from ws2_32.dll (WinSock): delphinet_getservbyname.html.