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,861 other subscribers

Archive for 2009

Delphi – bizarre use of class helpers to circumvent ‘with’

Posted by jpluimers on 2009/04/27

Quite a while ago, a co-worker asked how to get tot the Instance variable when using a with statement like this:

function TMyForm.ExecuteForm(FormClass: TFormClass): Integer;
begin
  with FormClass.Create(self) do
    try
      Result := ShowModal;
    finally
      Free;
    end;
end;

So I wrote the blog entry below when I started my blog last week, and set the published date to somewhere early May, a week that will be really busy.
Then I found out about the Stackoverflow question Reference object instance created using “with” in Delphi followed by the answer by user ‘Alexander‘ (a really smart Russian guy).
Enough coincidence to publish the blog article earlier than scheduled :-) 

Before I explain why I really hate ‘with’, lets show what my co-worker wanted, and my solution: Read the rest of this entry »

Posted in Delphi, Development, Pingback, Software Development, Stackoverflow | 2 Comments »

.NET/C# – Issue with FileStream on network with transfers larger than 64 megabyte

Posted by jpluimers on 2009/04/27

Quite a while ago (2006!), I bumped into an issue when copying large chuncks of data to a network.

I posted it to Google, mentioned that breaking up the data in smaller blocks worked, but never had the time to post the solution.

So here it is :-)

First the problem:

The old code consistently fails when:

  • the FileStream is on a network
  • and the MemoryStream is 64 megabytes or larger

The old code succeeds when:

  • the MemoryStream is smaller than 64 megabytes
  • or the FileStream is not on a network

An example of the exception message you get upon failure:

System.IO.IOException: Insufficient system resources exist to complete the requested service.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.WriteCore(Byte[] buffer, Int32 offset, Int32 count)
   at System.IO.FileStream.Write(Byte[] array, Int32 offset, Int32 count)
   at System.IO.BufferedStream.Write(Byte[] array, Int32 offset, Int32 count)
...

Then the old code:

        public static void WriteMemoryStreamToFile(string filename, MemoryStream memory)
        {
            using (Stream
                file = new FileStream(filename, FileMode.OpenOrCreate, FileAccess.ReadWrite),
                fileBuffer = new BufferedStream(file)
            )
            {
                byte[] memoryBuffer = memory.GetBuffer();
                int memoryLength = (int)memory.Length;
                fileBuffer.Write(memoryBuffer, 0, memoryLength); //##jpl: drawback: works only up to 2 gigabyte!
                fileBuffer.Close();
                file.Close();
            }
        }

Note that the old code already has a limitation of 2 gigabyte, back then this was not an issue (in 2006 there were not that many people having more than 2 gigabytes of memory, now that is a different story).

Read the rest of this entry »

Posted in .NET, C#, Development | 6 Comments »

Performed @ Bloemencorso Bollenstreek 2009 (Flowercorso 2009)

Posted by jpluimers on 2009/04/26

Yesterday, the Senior Band of Adest Musica (the marching band where next year I hope to celebrate my 30th membership anniversary) participated in the 62nd edition of the Flower Parade in “de Bollenstreek“.
(Actually this is should formally be called “de Duin- and Bollenstreek”, as the complete “Bollenstreek” also includes two more regions in North Holland, and a few smaller areas on the South Holland islands).

New truck for Adest Musica with "the Musketeer" theme for their WMC 2009 show

New truck for Adest Musica with “the Musketeer” theme for their WMC 2009 show

The Senior Band has brass and percussion (no woodwinds, though the Stage Band orchestra part of Adest Musica has them).

It will compete during the World Music Contest 2009 in Kerkrade, so this was a great opportunity to show the public our new marches that we are going to play at the WMC: “Moving Force” and “to Fight and Win” (sorry Dutch link only) as well as the introductory march to the show “Up is Down” that bridges our previous show “Legends of the Seas” to the new show “the Musketeer”.

At the flower corso, also our new truck themed “the Musketeer” as well, click on the picture on the right to see an enlarged version.

A few videos of the Flower Parade with us performing are already on-line:

  1. Adest Musica Sassenheim – Bloemencorso 2009 – WMC / The  – 10 minute compilation
  2. Adest Musica Sassenheim – Bloemencorso 2009 – 2.5 minute compilation showing “Up is Down”
  3. Adest Musica Sassenheim – Bloemencorso 25 april 2009 – very short fragment, but the only one showing my wife (light blue shirt) and brother (khaki jacket) having back-packs with fresh water!

So now you know what I do to balance all the keyboard work I do :-)

–jeroen

Posted in About, Adest Musica, Personal | Leave a Comment »

Conferences, seminars and other public appearances « The Wiert Corner

Posted by jpluimers on 2009/04/26

On request, I have started to maintain a page about the events I have spoken at or will be speaking at.

The page serves as a central landing spot for people wanting to download materials of past appearances, or wanting to meet me in person on future appearances.

Currently, it contains

I will extend it with more downloads and more events over time (and blog about it when it gets extended).

Drop me a message at the contact form when you need more of the past downloads (I have been speaking at conferencs since 1995, so there is quite a lot of material <g>)

Posted in About, Conferences, Delphi, Development, Event, PowerDay | Leave a Comment »

Spoken @ Delphi 2009 interactive briefing on April 1st, 2009 (no joke!) on migrating from Delphi 2007 to Delphi 2009, and from Delphi 5 to Delphi 2006/2007

Posted by jpluimers on 2009/04/26

Oosterkamp training | consultancy (the company that I used to co-own before partnering in better office benelux), together with Barnsten (the CodeGear / Embarcadero representative in the benelux) organized a Delphi 2009 interactive briefing on the evening of April 1st, 2009.

That wasn’t a joke, and we had good attendance with interesting questions.

I did a session on migrating to the most current Delphi version.

Read the rest of this entry »

Posted in Briefing, Delphi, Development, Event, Software Development | 1 Comment »

.NET/C# – obtaining information through WMI

Posted by jpluimers on 2009/04/25

WMI (Windows Management Instrumentation) is a way of obtaining information from your PC that otherwise might be hard to find.
WMI is based on Common Information Model (CIM), so you’ll see an example of that too.

There is one drawback: for a lot of the WMI, you need to have enough privileges (like: being an admin, which none of you should be, right?).
So beware!

You can use WMI from C#, but you have to generate the C# classes for the WMI classes first.

I’ll show some examples for WMI Win32 classes, as I needed some of those classes recently myself.

Before I forget:
in order to browse through the WMI Win32 object instances, you can download this nifty WMI Administrative Tools toolset from the Microsoft MSDN site. Note that these are from 2002, and they only reliably work from within Internet Explorer.
Read the rest of this entry »

Posted in .NET, C#, Development, Software Development, Visual Studio and tools | Leave a Comment »

Who is coming to DelphiLive? « Daniel Magin’s Weblog

Posted by jpluimers on 2009/04/24

My German colleague Daniel Magin is keeping track of people going to attend or speak at DelphiLive ’09.

Please leave a comment on his blog posting to help him assembling the list.

I’ll be arriving on the evening of  tuesday, May 12th, and leave in the morning of sunday May 17th (in order to keep the flight costs down, it is wise to include a Saturday/Sunday night stay).

–jeroen

Posted in Conferences, Event, Pingback | Leave a Comment »

Delphi – finding out the design-time package name of a unit

Posted by jpluimers on 2009/04/24

Somehow I keep forgetting this ‘be aware though’ part below, hence this blog post :-)
mmx-favicon_64x64-321

When you are developing packages, sometimes you need units that are part of the VCL/RTL source tree.
Normally when compiling such a package, Delphi suggests the depending VCL/RTL package to add to your required package list.
However, that does not always work, especially with design-time packages (those start with ‘dcl’ in stead of ‘vcl’).

The last time I bumped into this was when I developed a package that needed the MessageDigest_5 unit.
Read the rest of this entry »

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

Spoken @ CodeRage III, December 1-5, 2008 on Delphi, database and XML related topics

Posted by jpluimers on 2009/04/24

At the CodeRage III on-line virtual conference, I have done 4 sessions. CodeRage III logo
For me, it was the first time speaking at conference done this way.
A few things were different:

  • Sessions were 45 minutes presenting in stead of the normal 60 minutes
  • The main body of the session was pre-recorded, the 15 minute Q&A was live
  • I had to learn Camtasia
  • The broadcasts were done through LiveMeeting

Read the rest of this entry »

Posted in Audacity, Audio, Conferences, Development, Event, Internet, InternetArchive, Media, Power User, Software Development, WayBack machine, XML/XSD | 3 Comments »

.NET/C# – converting UTF8 to ASCII (yes, you *can* loose information with this) using System.Text.Encoding

Posted by jpluimers on 2009/04/23

Quite a while ago, we needed to exchange some text files with .NET and a DOS application (yes, they still exist!).

Since the .NET app already exchanged text files with other applications using UTF8, we had to reencode those into plain ASCII.
(yes, I am aware there are dozens of codepages we could encode to, we decided to stick with 7-bit ASCII, and warned the client about possible information loss).

A couple of months later, we neede to exchange information with an app doing Windows-1252, and then even later on to a web-app needing ISO 8859-1 (both are Western European encodings).
So I decided to refactor the UTF8 to ASCII conversion app into something more maintainable.

But first let me show you how you can dump all of the .NET supported encodings:
Read the rest of this entry »

Posted in .NET, ASCII, C#, Development, Encoding, Software Development, Unicode, UTF-8, UTF8 | 3 Comments »