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

Archive for the ‘Conferences’ Category

Dutch stop of the RAD Studio in Action LIVE! event: September 7th, Leiden (close to Amsterdam) with extra conference track.

Posted by jpluimers on 2013/08/27

The Dutch stop of the RAD Studio In Action LIVE! tour is on September 7th.

The venue location is via Holiday Inn Leiden Hotels: Haagse Schouwweg 10, 2332 KG  Leiden, The Netherlands.

It is close to the advertised “Amsterdam Netherlands” (about half an hour drive), close to the A44 highway and close enough to public transport. And it is indeed on Saturday September 7, 2013

Full day event: RAD Studio In Action LIVE! + conference track Read the rest of this entry »

Posted in Android, Android Devices, CodePlex, Conferences, Delphi, Delphi XE4, Delphi XE5, Development, DVCS - Distributed Version Control, Event, FreePascal, git, iOS Development, Lazarus, Mercurial/Hg, Mobile Development, Power User, Software Development, Source Code Management, SourceForge, Subversion/SVN, TFS (Team Foundation System) | Leave a Comment »

.NET/C#: UnitPrefixes class that facilitates distinguishing decimal and binary file/drive/memory size (mega versus mibi, etc)

Posted by jpluimers on 2013/08/14

Everyone knows there is a size difference between a gigabyte of memory, and a gigabyte of disk space.

The former is 102410241024, the latter is 100010001000.

To facilitate this, I’ve created a C# class UnitPrefixes containing quite a few constants and readonly values.

The class is below, but a few interesting facts first:

  • Most values are const, but a few are readonly static variables because they cannot calculated at compile time (the C# compiler by design does very limited calculations at compile time; it is complex enough as it already is).
    As Jon Skeet explains, there are some other differences between const and readonly static, which is why I favour const.
  • Though all consts are positive, I could have used UInt32 and UInt64, but the .NET framework favours signed Int32 and Int64 types for parameters, so to avoid casting, I used the signed ones.
  • There is no Int128 or UInt128, but there is System.Numerics.BigInteger which I use for values too large for 64-bit integers.
    Note that BigInteger is relatively new, so this code will only work in C# 4 or higher, and requires .NET 4 or higher.
    This is also the place where I use the public readonly static fields, as I need to call the BigInteger constructor to initialize it.
  • I used the Decimal type, as the mantissa holds up to 28 digits of accuracy.

I used the Wikipedia pages Binary Prefix and Metric Prefix (I could also have used File Size) for the unit names and abbreviations.

Note that BitsPerByte is a const I needed too, and I will probably add constants for 512 and 4096, as you see those often in computing as well.

The below sample code is also available as a changeset on BeSharp.CodePlex.com. Read the rest of this entry »

Posted in .NET, .NET 4.0, .NET 4.5, C#, C# 4.0, C# 5.0, Conference Topics, Conferences, Development, Event, Jon Skeet, Software Development | Tagged: , | Leave a Comment »

Reminiscence of the past: Delphi I/O error 131

Posted by jpluimers on 2013/08/06

I was called by a client that didn’t want to do maintenance on an old Delphi application, but wanted to get dir of an I/O Error 131:

I/O Error 131: ERROR_NEGATIVE_SEEK

MessageText: An attempt was made to move the file pointer before the beginning of the file.

Tough luck: psychic powers told me someone is using an unsigned 32-bit integer to access a file using traditional style Assign/Reset/Seek/Read/Close patterns that Delphi kept as intrinsic routines for Turbo Pascal backward compatibility, and that file has grown over 2 gigabyte in size.

I quickly found an import file had grown over the 2 gigabyte, so this was indeed the case.

The original developers didn’t do the file access using the 64-bit Seek/Position of the TStream descendant TFileStream.

Too bad, as now someone has to dig through the mothballs to find the sources (if they survived 3 different version control system switches), create a working development environment, and fix the bug.

Another instance where technical debt in IT raises its ugly head and the compound interest is really expensive.

–jeroen

via: erikmartin.com – IO Errors in Delphi.

Posted in Conference Topics, Conferences, Delphi, Delphi 5, Development, Event, Software Development, Technical Debt | 14 Comments »

A few notes on Delphi, WSDL and SOAP: passing nil values, Document/Literal versus RPC Encoded

Posted by jpluimers on 2013/05/14

I had some notes on Delphi WSDL and SOAP peculiarities somewhere, but I misplaced them.

Luckily, I found some links that explain most of my notes well:

–jeroen

Posted in Conference Topics, Conferences, Delphi, Delphi 2007, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Development, Event, SOAP/WebServices, Software Development | Leave a Comment »

Delphi: you should avoid the `with` statement as it makes your code less future proof

Posted by jpluimers on 2013/03/27

As I wrote before, I’m with the [WayBack] Delphi with haters camp, and this is why:

Using the [WayBackwith statement in Delphi makes your code less future proof.

Originally, the with statement in Pascal was argumented in part of allowing compiler optimisations:

PASCAL User Manual and Report – Kathleen Jensen, Niklaus Wirth – Google Books

The with clause effectively opens the scope containing field identifiers of the specified record variable, so that the field identifiers may occur as variable identifiers. (Thereby providing an opportunity for the compiler to optimize the qualified statement.)

Screenshots of this 1975 book are below the fold.

The Delphi (actually even before that Turbo Pascal compiler) has no measurable difference between with and non-with code.

The debugger however, still does not support with, and there are other drawbacks of which one is below.

The below code example is just one of many. I show it because I recently bumped into doing some long overdue code porting to Delphi XE3.

Since I’ve been bitten by using with a couple of times before, it didn’t take me long to find the cause.

Example code where FIConData is of type NOTIFYICONDATAW that used to compile fine:

    with FIconData do
    begin
      cbSize := SizeOf(FIconData);
      Wnd := Self.Handle;
      uID := $DEDB;
      uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP;
      hIcon := Application.Icon.Handle;
      uCallbackMessage := WM_CAS400NTIcon;
      StrCopy(szTip, PChar(Caption));
    end;

Well, as of Compiler Version 20, it doesn’t compile any more. Read the rest of this entry »

Posted in Borland Pascal, Conference Topics, Conferences, Delphi, Delphi 1, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 3, Delphi 4, Delphi 5, Delphi 6, Delphi 7, Delphi XE, Delphi XE2, Delphi XE3, Development, Event, Pascal, Software Development, Turbo Pascal, With statement | 32 Comments »

ntfs – How do you find what process is holding a file open in Windows? – Server Fault

Posted by jpluimers on 2013/03/15

First a warning: when you have found the process holding open a file, and you want to forcibly close the handle, read this post why you should not: Windows Confidential: Forcing Handles Closed.

In fact:

if you forcibly need to close a handle to salvage something, you should reboot shortly afterwards.

Back to the question at hand:

How do you find what process is holding a file open in Windows?

One thing that annoys me no end about Windows is the old “sharing violation” error. Often you can’t identify what’s holding it open. Usually it’s just an editor or explorer just pointing to a relevant directory but sometimes I’ve had to resort to rebooting my machine.

Any suggestions on how to find the culprit?

All of the below solutions require you to run with Administrative privileges.

On current Windows versions, if you run them without UAC elevation, they will miss a lot of processes. And still: under some secured environments you won’t see all processes anyway.

My preferred answer is not on the list:

Quit the application that holds the handle

All the tools that show you the handles will indicate which process holds the handle.

Often, you can just quit that process, do your job on the affected file, then relaunch that process.

When the process is Explorer, there is a neat little trick that works for Windows Vista and up:

For explorer, btw, hold ctrl-shift and right-click a blank area of the start menu, and you’ll get “Exit Explorer” – ps, not quite Jeff’s answer.. – Mark Sowul

Another answer I like is to use Handle, as it is both a command-line tool, and allows for wildcard searching: Read the rest of this entry »

Posted in Conference Topics, Conferences, Event, Power User, Windows, Windows 7, Windows 8, Windows Server 2000, Windows Server 2003, Windows Server 2003 R2, Windows Server 2008, Windows Server 2008 R2, Windows Vista, Windows XP | Leave a Comment »

Delphi “Variant Records”, a few notes

Posted by jpluimers on 2013/03/14

Variant Records are a feature that has been in the Pascal language since Standard Pascal.

A cool page for historic perspective is R3R: Pascal Features in Popular Compilers, hopefully someone will update it to more modern versions of the mentioned compilers.

There is not much official documentation on the Delphi side on this, so below some parts of a case I used for a project that started in 1997 and is still in use to day. Read the rest of this entry »

Posted in APPC, AS/400 / iSeries / System i, ASCII, COBOL, Communications Development, Conference Topics, Conferences, CPI-C, Delphi, Delphi 1, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 3, Delphi 4, Delphi 5, Delphi 6, Delphi 7, Delphi 8, Delphi XE, Delphi XE2, Delphi XE3, Development, Encoding, Event, HIS Host Integration Services, Internet protocol suite, MQ Message Queueing/Queuing, SNA, Software Development, TCP, Unicode, UTF-8, WebSphere MQ | 9 Comments »

If you think CSV is easy; think again!

Posted by jpluimers on 2012/12/05

Lots of people think CSV is easy: it’s just a bunch of values separated with commas. But in practice it is not. Various reasons can make CSV very hard, especially since “CSV” is not a single, well-defined format. As always importing is always harder than exporting. A few reasons that make it hard:

A few links that helped me a lot getting input and output of CSV right in C#:

Thanks to Jabulaza:

–jeroen

via: Comma-separated values – Wikipedia, the free encyclopedia.

Posted in Conference Topics, Conferences, CSV, Development, EBCDIC, Encoding, Event, Software Development | 4 Comments »

My Delphi conferences this fall: DelphiTage.de, ITDevCon.it, no EKON (entwickler-konferenz.de)

Posted by jpluimers on 2012/09/19

Nicolette and me on the Antarctic peninsulaWhile scheduling this year’s projects, it was clear that it would become impossible to have the summer holiday in the summer (last year was also outside, as we fulfilled Nicolette’s dream: visit the Antarctic region).

So we moved this year’s holiday to early November, hoping that would be outside the Fall conference season.

Alas, EKON (Entwickler-Konferenz.de), this year in Düsseldorf, Germany, moved themselves to November, so this will be the first EKON ever that I won’t attend (out of 3 or 4 people that never missed one). Sorry guys I will miss the great speakers, sessions and workshops (:

I am going to speak on two other European Delphi conferences though:

I’m really looking forward meeting the attendees, speakers and organizations there. Conferences are always a lot of fun and a great way for me of learning new things.

--jeroen

via:

Posted in About, Antarctic, Conferences, Delphi, Delphi XE2, Delphi XE3, Delphi-Tage.de, Development, EKON, Event, ITDevCon, Personal, Software Development, Travel | Tagged: , , , , , , , , , , , , , , , , , , , , | 2 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 »