The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,860 other subscribers

Archive for the ‘Delphi’ Category

Delphi Code Monkey: Why Delphi developers should learn Objective-C and XCode

Posted by jpluimers on 2013/01/08

I’ve requested the feed of Delphi Code Monkey by Warren Postma to be added to DelphiFeeds.

In the mean time, read this post, it is awesome: Delphi Code Monkey: Why Delphi developers should learn Objective-C and XCode.

–jeroen

Posted in Delphi, Development, Software Development | Tagged: , , , , | 4 Comments »

Delphi and C# compiler oddities

Posted by jpluimers on 2013/01/08

When developing in multiple languages, it sometimes is funny to see how they differ in compiler oddities.

Below are a few on const examples.

Basically, in C# you cannot go from a char const to a string const, and chars are a special kind of int.

In Delphi you cannot go from a string to a char. Read the rest of this entry »

Posted in .NET, ASCII, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Delphi, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Development, Encoding, Software Development, Unicode | Leave a Comment »

x64 debugging on Windows: usually not directly by the IDE, but trough a debug helper process (msvsmon / PAServer / dbkw64_16_0)

Posted by jpluimers on 2012/12/07

While developing x64 applications, most Windows development tools are actually running in x86 mode, and use an intermediate x64 layer to debug the x64 process even for local debugging.

For Visual Studio 2008 and up, this is msvsmon.exe (for Delphi XE2 and up it is PAServer.exe for remote debugging or [WayBack] dbkw64_16_0.exe for local debugging, other tools use a similar mechanism).

The fun thing with Visual Studio is that when msvsmon.exe fails to load locally, you get a misleading error message:

[Microsoft Visual Studio]
Error while trying to run project: Unable to start debugging.
The Microsoft Visual Studio Remote Debugging Monitor has been closed on the remote machine.
[OK]

I found two workarounds myself :

  1. Kill msvsmon.exe if it is running but Visual Studio cannot talk to it
  2. Restart Visual Studio if it cannot start msvsmon.exe

I learned the why from Steve Steiner: he posted the StackOverflow answer explaining msvsmon.exe is also used for local x64 debugging.

Delphi XE2 and up sometimes have a similar cryptic message (I forgot to jolt it down, next time I come across it, I will edit this blog post) and usually killing PAServer.exe or dbkw63*.exe or restarting the IDE solves it.

–jeroen

via:

Posted in .NET, Debugging, Delphi, Delphi x64, Development, QC, Remote Debugging, Software Development, Visual Studio 11, Visual Studio 2008, Visual Studio 2010, Visual Studio and tools | Leave a Comment »

C#: any c# – .NET Enumeration allows comma in the last field – Stack Overflow

Posted by jpluimers on 2012/12/06

Thanks Nick Craver for answering this on StackOverflow.

Array initializers can be specified in field declarations (§17.4), local variable declarations (§15.5.1), and
array creation expressions (§14.5.10.2).

The array initializer can end in a comma, which makes some things way easier (boy, I wish I had this in other programming languages).

From Nick’s answer:

It has no special meaning, just the way the compiler works, it’s mainly for this reason:

[FlagsAttribute]
public enum DependencyPropertyOptions : byte
{
Default = 1,
ReadOnly = 2,
Optional = 4,
DelegateProperty = 32,
Metadata = 8,
NonSerialized = 16,
//EnumPropertyIWantToCommentOutEasily = 32
}
[/language]By comment request: This info comes straight out of the ECMA C# Specification (Page 363/Section 19.7)

“Like Standard C++, C# allows a trailing comma at the end of an array-initializer. This syntax provides flexibility in adding or deleting members from such a list, and simplifies machine generation of such lists.”

–jeroen

via c# – .NET Enumeration allows comma in the last field – Stack Overflow.

Posted in .NET, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, C++, Delphi, Development, Java, JavaScript/ECMAScript, PHP, Software Development, VB.NET | 5 Comments »

.NET/C# duh moment of the day: “A char can be implicitly converted to ushort, int, uint, long, ulong, float, double, or decimal (not the other way around; implicit != implicit)”

Posted by jpluimers on 2012/11/20

A while ago I had a “duh” moment while calling a method that had many overloads, and one of the overloads was using int, not the char I’d expect.

The result was that a default value for that char was used, and my parameter was interpreted as a (very small) buffer size. I only found out something went wrong when writing unit tests around my code.

The culprit is this C# char feature (other implicit type conversions nicely summarized by Muhammad Javed):

A char can be implicitly converted to ushort, int, uint, long, ulong, float, double, or decimal. However, there are no implicit conversions from other types to the char type.

Switching between various development environments, I totally forgot this is the case in languages based on C and Java ancestry. But not in VB and Delphi ancestry  (C/C++ do numeric promotions of char to int and Java widens 2-byte char to 4-byte int; Delphi and VB.net don’t).

I’m not the only one who was confused, so Eric Lippert wrote a nice blog post on it in 2009: Why does char convert implicitly to ushort but not vice versa? – Fabulous Adventures In Coding – Site Home – MSDN Blogs.

Basically, it is the C ancestry: a char is an integral type always known to contain an integer value representing a Unicode character. The opposite is not true: an integer type is not always representing a Unicode character.

Lesson learned: if you have a large number of overloads (either writing them or using them) watch for mixing char and int parameters.

Note that overload resolution can be diffucult enough (C# 3 had breaking changes and C# 4 had breaking changes too, and those are only for C#), so don’t make it more difficult than it should be (:

Below a few examples in C# and VB and their IL disassemblies to illustrate their differnces based on asterisk (*) and space ( ) that also show that not all implicits are created equal: Decimal is done at run-time, the rest at compile time.

Note that the order of the methods is alphabetic, but the calls are in order of the type and size of the numeric types (integral types, then floating point types, then decimal).

A few interesting observations:

  • The C# compiler implicitly converts char with all calls except for decimal, where an implicit conversion at run time is used:
    L_004c: call valuetype [mscorlib]System.Decimal [mscorlib]System.Decimal::op_Implicit(char)
    L_0051: call void CharIntCompatibilityCSharp.Program::writeLineDecimal(valuetype [mscorlib]System.Decimal)
  • Same for implicit conversion of byte to the other types, though here the C# and VB.NET compilers generate slightly different code for run-time conversion.
    C# uses an implicit conversion:
    L_00af: ldloc.1
    L_00b0: call valuetype [mscorlib]System.Decimal [mscorlib]System.Decimal::op_Implicit(uint8)
    L_00b5: call void CharIntCompatibilityCSharp.Program::writeLineDecimal(valuetype [mscorlib]System.Decimal)
    VB.NET calls a constructor:
    L_006e: ldloc.1
    L_006f: newobj instance void [mscorlib]System.Decimal::.ctor(int32)
    L_0075: call void CharIntCompatibilityVB.Program::writeLineDecimal(valuetype [mscorlib]System.Decimal)

Here is the example code: Read the rest of this entry »

Posted in .NET, Agile, Algorithms, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, C++, Delphi, Development, Encoding, Floating point handling, Java, Software Development, Unicode, Unit Testing, VB.NET | 1 Comment »

Twitter / alexnolannet: New utility: PDX Viewer Plus does not require drivers or an install…

Posted by jpluimers on 2012/10/08

Nice!:

New utility: PDX Viewer Plus 1.00 beta. A simple Paradox Database Viewer that does not require drivers or an install.

–jeroen

via: Twitter / alexnolannet: New utility: PDX Viewer Plus ….

Posted in Database Development, Delphi, Development, Paradox, Power User, Software Development | Leave a Comment »

Jim Tierney published some great Delphi XE3 LiveBinding posts

Posted by jpluimers on 2012/10/03

Jim Tierney isn’t on DelphiFeeds yet, so below are a few links to his great Delphi XE3 LiveBindings posts.

Jim is one of the people that developed LiveBindings. In addition to that, he explains things very well.

He did some great posts on LiveBindings after Delphi XE2 got launched (he also did two great presentations on Delphi Live 2011 and CodeRage 6 – they got repeated on the last 24 hours of Delphi).

Now he is publishing a series of posts on LiveBindings in Delphi XE3.

These posts are recommended reading, more are probably on their way:

–jeroen

via: Jim Tierney

Posted in Delphi, Delphi XE3, Development, Software Development | Tagged: , , , , , , , | Leave a Comment »

Three XE3 hotfixes at the Delphi Registered User Downloads page

Posted by jpluimers on 2012/09/28

There are three RAD Studio / Delphi XE3 hotfixes on the Delphi Registered User Downloads page.

Hotfix 3 is for the Professional edition only.

The others are for all editions.

RAD Studio XE3 Hotfix 3: Hotfix 3 for RAD Studio XE3.

This Hotfix addresses an issue in using SQLite driver on the Professional edition.

Available only to registered users of Professional edition of Delphi XE3, C++Builder XE3, RAD Studio XE3, and Embarcadero All-Access XE

1MB; Download

RAD Studio XE3 Hotfix 2: Hotfix 2 for RAD Studio XE3.

This Hotfix addresses a regression with using the GestureManager in a FireMonkey application.

Available only to registered users of Delphi XE3, C++Builder XE3, RAD Studio XE3, and Embarcadero All-Access XE

60MBDownload

RAD Studio XE3 Hotfix 1: Hotfix 1 for RAD Studio XE3.

This Hotfix addresses an issue with ShowMessage in a FireMonkey application on certain locales on Mac OS X.

Available only to registered users of Delphi XE3, C++Builder XE3, RAD Studio XE3, and Embarcadero All-Access XE

12.1MBDownload

–jeroen

via: Delphi Registered User Downloads.

Posted in Delphi, Delphi XE3, Development, Software Development | Tagged: , , , , , , , , , , | 5 Comments »

Delphi: path names both in .dpr and .dproj, why? (refactoring – How to reorganize the folder structure of my units in Delphi? – Stack Overflow)

Posted by jpluimers on 2012/09/27

Cool: learned something new here:

About the path names of files being in the .dproj as well as in the .dpr:

@Jeroen – Looks like msbuild might need those entries, otherwise they’re possibly redundant, AFAICT… In any case, there is not much editing involved, just delete ‘dccreference’ entries and then a ‘save all’ in the IDE regenerates them. – Sertac Akyuz

–jeroen

via: refactoring – How to reorganize the folder structure of my units in Delphi? – Stack Overflow.

Posted in Delphi, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Development, Software Development | Tagged: , , , , , , | 14 Comments »

Upscene Productions: Database Workbench 4.3.1 free Lite Editions released

Posted by jpluimers on 2012/09/26

Database Workbench is my tool of choice for doing database work: it supports many backends in a consistent manner, and behaves a lot like Delphi (like running and debugging stored procedures).

Yesterday the free Lite Editions of Version 4.3.1 got released:

Database Workbench 4.3.1 free Lite Editions released

This new release of Database Workbench brings new features and enhancements, as requested by our users.

The free Lite Editions are now available.

More information about Database Workbench is available at the Database Workbench page, download your copy today via our downloads page, pricing information is available, the limited Lite Editions are available for free.

Changes in this release

  • The full details and list of changes are available here and here.
  • New
  • MySQL Stored Procedure, Function and Trigger Debugging (Pro Edition only)
  • InterBase and Firebird syntax check in Trigger Editor (Pro Edition only)
  • Incremental search of data in SQL, Table and View Editor

Changes

  • More compact taskbar
  • MySQL support for BINARY and VARBINARY datatypes
  • MySQL error fixed when not having access to mysql.procs
  • MySQL fix for fetching foreign key information
  • Data Import and Export fixes
  • Windows 7 event log error by SideBySide fixed

And much more…

–jeroen

via News @ Upscene Productions.

ITDevCon: Oct 25/26 2012 in Verona, Italy

Posted in Database Development, Delphi, Development, Firebird, InterBase, MySQL, OracleDB, PostgreSQL, Software Development, SQL, SQL Server, SQL Server 2000, SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012, SQL Server 7 | 1 Comment »