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 2007: reproduction and workaround for “[DCC Error] ….pas(26): F2084 Internal Error: AV21BCE0AC-R00000000-0”

Posted by jpluimers on 2012/07/31

Just in case you come across this error ([WayBackQC 108189):

[DCC Error] CompilerAVUnit.pas(26): F2084 Internal Error: AV21BCE0AC-R00000000-0

I had this error in a really complicated unit that I tried to backport from Delphi XE2 to Delphi 2007 (as there was some non-unicode compliant app that needed this).

I could not find it searching for F2084 Internal Error, so I sat down and trimmed it down to the CompilerAVUnit below.

The workaround is simple: remove the static; from method Outer and it compiles fine.

I will post more details on the static keyword in Delphi in a future blog post. For now I’ll keep it at this: Read the rest of this entry »

Posted in Delphi, Delphi 2007, Development, F2084, QC, Software Development | 8 Comments »

which kind of IsHex() function do you like most, and why?

Posted by jpluimers on 2012/07/10

Though the sample question is in C#, it applies to almost any language and framework: for relatively simple checks like IsHex(), you can go the RegEx way, or the compound if-statement way.

Which kind of function do you like most?

I’m not only interested in the percentages, so let me know in the comments why.

–jeroen

PS: if you want to use RegEx in .NET, you can compile them to IL, but be very cautious for the compilation overhead.

Posted in .NET, C#, COBOL, Delphi, Development, JavaScript/ECMAScript, PHP, RegEx, Scripting, Software Development, VB.NET | 8 Comments »

Dear fellow programmer. If you aren’t experienced doing multi-threading, please don’t!

Posted by jpluimers on 2012/07/05

Recently I was asked to investigate a performance problem with a certain .NET application.

The first error I got when getting the app to build in Visual Studio 2010, and then run it was like this:

System.ComponentModel.InvalidAsynchronousStateException was caught
  Message=An error occurred invoking the method.  The destination thread no longer exists.
  Source=System.Windows.Forms
  StackTrace:
       at System.Windows.Forms.Control.WaitForWaitHandle(WaitHandle waitHandle)
       at System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous)
       at System.Windows.Forms.Control.Invoke(Delegate method, Object[] args)
       at UI.Splash.SetStatus(String status) in C:\...\Splash.cs:line 395
       at UI.Menu.Main() in C:\...\Menu.cs:line 4275
  InnerException:

Someone built their own splash logic with multi-threading.

Funny that today, this got answered on StackOverflow by [WayBackmgie: [WayBack] multithreading – TMonitor synchronization / Application.ProcessMessages – Stack Overflow.

Though that is a Delphi link (and points to the nice libraries [Archive.is] AsynCalls and [WayBack] OmniThreadLibrary), the most important link it contains is to  [WayBackBorland Newsgroup Archive :: borland.public.delphi.internet.winsock :: Re: Disconnect TIdHttp in thread.

That sounds like a Delphi link too, but the subtitle “‘Ways to get into avoidable trouble with threads, V1.2′” hints the essence: it is a post that describes in an environment-agnostic way how to avoid multi-threading problems.

Recommended reading!

Anyway: Building multi-threaded code is hard. Even harder fleshing out all the corner cases and potential error conditions.

No matter what kind of programming environment: If you have not done lots of multi-threaded programming, then please don’t do it yourself: go ask someone that does know how to do it. Or better, try to avoid it.

I try to let libraries to the handling of multi-threading for me, if I use multi-threading at all, as others are far better at this than I am.

–jeroen

Posted in .NET, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Conference Topics, Conferences, Delphi, Development, Event, Java, Software Development, VB.NET, VBS, Visual Studio 2010, Visual Studio and tools, WinForms | 6 Comments »

Hollerith and why we have digraphs in Pascal and trigraphs in C/C++ (nostalgia, Apple ][ plus)

Posted by jpluimers on 2012/07/04

Apple ][ plus keyboardSome nostalgia (:

In the mid 80s, when programming in UCSD Pascal and Turbo Pascal, I learned that Pascal has (. and .) digraphs that translate into [ and ], similar to the (* and *) digraphs that translate to { and }.

In fact I thought the English word was bigraph (as bi- is a prefix for twice, just like tri- is a prefix for thirce).
The digraphs are lexical alternatives (Pascal ISO  standard 7185:1990 paragraph 6.1.9 or Extended Pascal ISO standard 10260:1990 paragraph 6.1.11). There is even one more: the @ at-sign is a lexical alternative for the ^ caret.

Back then (I was in my teens, there was no internet yet and school library had nothing on programming) I thought these were because keyboards like those of the Apple ][ plus couldn’t emit [ and ], but I was wrong: it was in fact the Hollerith Card Code that could not represent these characters.

That limitation was because of the first Pascal implementation was done on a CDC 6000 series that used punched card readers/writers.  You could not punch arbitrary numbers of holes on each row (lace cards lacked structural strength) limiting the character codes you can represent.

They still work in the Delphi compiler for arrays and for comments (I just learned that various Pascal implementations use different rules of mixing digraph and normal comments (some even allow nesting)).

While I taught myself C and C++ just as I taught myself Pascal, somehow I never learned that they use lexical alternatives too. It was only recently that they do, both as trigraphs and as of C99 also as digraphs and that there is even a trigraph tool as part of the C++ personality of RAD Studio 2007.

–jeroen

Posted in Apple, Apple ][, C++, Delphi, Development, History, Keyboards and Keyboard Shortcuts, Power User, Software Development | 1 Comment »

Visual Studio and Delphi: Getting a new GUID in the code editor

Posted by jpluimers on 2012/06/28

Earlier this week, I already wrote about different idioms in different IDEs.

Here is another one, again a feature I don’t use often: getting a fresh GUID in the IDE. Read the rest of this entry »

Posted in .NET, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Delphi, Development, Software Development, Visual Studio and tools | 7 Comments »

Embarcadero has some cool new Delphi iOS technology in the pipeline (via: Xcode – Debug iOS application on device without symbols – Stack Overflow)

Posted by jpluimers on 2012/06/27

Today exactly a month ago, Allen Bauer (Chief Scientist at Embarcadero) asked a really in depth question about debugging the startup sequence of iOS apps on a device not originating from Xcode on Stack Overflow indicating on what Embarcadero is researching.

Last week, he also answered the same question using manual steps for GDB. Not easy, but it works.

For a development tools company, getting your tools to work on a new platform is hard, and in this case it seems exceptionally hard.

I’m really looking forward to see what kind of cool tools come out of this, as the current developemt platform choices (Xcode or MonoTouch) can really use more competition to make it easier for us developers.

Exciting times ahead (:

–jeroen

via: xcode – Debug iOS application on device without symbols – Stack Overflow.

PS:  I really love the comment by Danny Thorpe on using Periscope breakout switches – I remember those NMI days well (:

Posted in Debugging, Delphi, Development, GDB, iOS Development, Mobile Development, Software Development, xCode/Mac/iPad/iPhone/iOS/cocoa | 4 Comments »

Stefan Glienke on Delphi generics: Implementing List Enumerator OfType in Delphi – Stack Overflow

Posted by jpluimers on 2012/06/26

Stefan Glienke posted a nice StackOverflow answer on some things to watch for when using Delphi Generics to implement an IEnumerator of type for a generic usage that works better than the stock one.

–jeroen

via:generics – Implementing List Enumerator OfType in Delphi – Stack Overflow.

Posted in Delphi, Development, Software Development | 3 Comments »

Repeating characters into strings in C# and Delphi (via: .net – Best way to repeat a character in C# – Stack Overflow)

Posted by jpluimers on 2012/06/26

Switching back and forth between mainly Delphi and C#, sometimes it is hard to remember which idiom works best in each environment.

Recently, I had to dupe a lot of tab characters for some Tab-Delimited interface to an archaic system.

I remembered the Delphi idiom: use the DupeString function as about Delphi explains (yes, I know: it dupes more than just characters).

In C#, these work best for me:

Small code sample of the first way (thanks CMS):

static string Tabs(int n)
{
    return new String('\t', n);
}

–jeroen

via: .net – Best way to repeat a character in C# – Stack Overflow.

Oh BTW: I have reduced my StackOverflow presence. It looks like the success of StackOverflow made them instantiate many moderators. A lot of those moderators work under the mantra “we follow the rules strictly, and favour punishment over encouragement” (some  even talk about “changing heritage“). That’s a real pity, as I see a lot of StackOverflow users get scared by the very active downvoting, question/answer closing and even deletion of material that is in essence valuable, if it were edited up a bit. Deleting content is always bad, as it increases the link rot that StackOverflow are trying to prevent in questions/answers as per their FAQ. Links are the foundation of the web.

Alas, devoting real attention to the quality of StackOverflow requires putting real energy in it, which for some of the moderators seems to be too much to ask.

Posted in .NET, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Delphi, Development, Pingback, Software Development, Stackoverflow | 5 Comments »

Delphi: [##] numbers in DFM files determine order of subcomponents (via: Strange [number]s in Delphi DFM files – origin and necessity? – Stack Overflow)

Posted by jpluimers on 2012/06/21

Another interesting SO thread that explains [##] numbers in DFM files.

They are used to determine the order of subcomponents when using form/frame inheritance.

–jeroen

via: Strange [number]s in Delphi DFM files – origin and necessity? – Stack Overflow.

Posted in Delphi, Development, Software Development | Leave a Comment »

Strong name for Interop.Scripting – .NET Framework

Posted by jpluimers on 2012/06/20

So I won’t forget:

I was trying to generate from the interop.scripting.dll which I guess was the automatically generated dll without strong naming. A wrapperof a wrapper apperently doesnt work.
The following did work:

tlbimp.exe C:\WINDOWS\system32\scrrun.dll /keyfile:..\nameHere.snk /out:Interop.Scripting.StrongNamed.dll

The suite of .NET projects I’m refactoring relies in part on scripting in the Microsoft Script Runtime because the original was build by people bringing their COM love from the VB6 world into the .NET world.

I don’t see COM as the first class citizen it was in the VB6 era. On the other hand, COM and ActiveX play an important role in the .NET world. Sometimes I regret that, as dealing with COM is hard.

Some consider COM a first class citizen in .NET as it was in VB6, especially after the dynamic keyword was added in C# 4.0. The variant type available since Delphi 2 since 1996 does more or less the same as dynamic keyword in C#. I know how Anders Heijlsberg disliked the Delphi Variant support of COM. But COM is what the market wanted in 1996, and that seems true until today.

But I digress.

At least parts of the .NET code needs to become strongly named, so I’m hesitating:

  1. kick out the COM stuff – and verify through unit tests that the encompassing code still works – or
  2. generate a strongly named COM Interop Wrapper as described above.

Not sure yet.

Opinions anyone?

Anyway, I’m expecting a few problems here and there, so I’ll be using the CLR Interop Tools like the P/Invoke Interop Assistant and Type Library Importer in Managed Code where needed.

–jeroen

via: Strong name for Interop.Scripting – .NET Framework.

Posted in .NET, C#, Delphi, Development, Software Development, VB.NET | 1 Comment »