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 the ‘.NET’ Category

WebSphere MQ and Delphi

Posted by jpluimers on 2011/07/21

On my research list: WebSphere MQ and Delphi.

The funny thing is that this Delphi MQ Series question on StackOverflow that I answered actually helped me to get going :)

A few interesting links:

The research actually is focussed to replace a APPC/CPI-C session based solution that runs on top of SNA using LU 6.2 endpoints and has round-trip response times between 50 and 150 milliseconds with a WebSphere MQ based solution having similar performance characteristics. It binds multiple client applications to multiple function entries on the AS/400 systems at the client.

The current APPC/CPI-C part is written either both a DLL and EXE in Delphi (depending on how it is used), hence the Delphi part of the research.

In many organizations, WebSphere MQ (aka MQSeries) is part of their Enterprise Service Bus. In that regard, the SNA solution was far a ahead of its time.

BTW: Back then (almost 15 years ago), the SNA solution started out as solution using AS/400 Data Queues. Even after months of trying, that didn’t work well because the mixed environment of NetSoft Router, AS/400, SNA Server and Windows NT 4 in a pretty big WAN had huge problems.
Somehow, one of the layers forced sessions to always use 2 connections at a time, which was causing huge problems when those were routed through different SNA servers. That routing was unpredictable (and it was not possible to disable/force it to use stick to one SNA server). In addition, it was memory and CPU hungry on the PC side (when you were glad to have a Pentium MMX based CPU with 32 MB RAM, it ate 20+% of the CPU power, and 25+% of the memory per session, peaking to 100% CPU and 50% of RAM per session).
Specialists from all involved parties weren’t able to pinpoint the actual cause, so we went a few steps down on the OSI layer to the APPC leve.

–jeroen

Posted in .NET, Delphi, Development, Software Development | 5 Comments »

File extension parameters do include a dot

Posted by jpluimers on 2011/07/20

This is from a long time ago, but still fun:

Sometimes simple things in life are hard do remember.

For instance, I always forgot if a file extension parameter should have a dot in it or not.

Normally it should!

But for clearing an extension, you should use a blank string.

Be aware though that empty extensions look differently depending where in the process you look at them:

C# example:

using System;
using System.IO;
public class Test
{
        public static void Main()
        {
                string extensionLess = Path.ChangeExtension(@"C:\mydir\myfile.com.extension", "");
                Console.WriteLine(extensionLess);
                string extension = Path.GetExtension(extensionLess);
                Console.WriteLine(extension);
        }
}

Outputs:

C:\mydir\myfile.com.

Delphi example:

program Demo;
{$APPTYPE CONSOLE}
uses
  SysUtils;
var
  extensionLess: string;
  extension: string;
begin
  extensionLess := ChangeFileExt('C:\mydir\myfile.com.extension', '');
  Writeln(extensionLess);
  extension := ExtractFileExt(extensionLess);
  Writeln(extension);
end.

Outputs:

C:\mydir\myfile.com
.com

Don’t you love differences in your platforms :)

–jeroen

Posted in .NET, C#, C# 2.0, C# 3.0, C# 4.0, Delphi, Development, Software Development | 4 Comments »

Extracting MSI files

Posted by jpluimers on 2011/07/13

Extracting MSI files can be a pain.

Some compression programs (like 7zip) can unpack them, but leave the unpacked filenames as gibberish.

Many people recommend using msiexec (link to technet docs) on the commandline using the /a parameter (which does an administrative install effectively unpacking it), but others prefer integration in Windows Explorer.

msiexec /a PathToMSIFile /qb TARGETDIR=DirectoryToExtractTo

There are many tools allowing to unpack, and the best seems to be LessMSIerables by Scott Willeke which used to be on the (now defunct) pingpoet blogs, but got resurrected as lessmsi at oogle code.

Note that LessMSI doesn’t always work when msiexec /a works; for instance, I once got this error message:

Error: System.Runtime.InteropServices.COMException (0x00000003): Failed to close cab extract object, error: 3

Note that when you want to view MST files in addition to MSI files, then you need MSTVIEW from ORK XP or ORK 2003 (which you can get through the Office 2003 resource kit downloads page).

–jeroen

Posted in .NET, Development, Power User, Software Development | 2 Comments »

Code Quality: the rate of WTFs

Posted by jpluimers on 2011/07/06

OSnews has an interesting view on code quality: the number of WTFs/minute.

I know it is from 2008, but it is so true, so I’m glad I re-found it.

–jeroen

via: wtfm.jpg (500×471).

Posted in .NET, Agile, Delphi, Development, Opinions, Software Development | Leave a Comment »

winapi – Best way to do non-flickering, segmented graphics updates in Delphi? – Stack Overflow

Posted by jpluimers on 2011/07/05

Recently, Jon Lennart Aasenden (of Surface Library fame) asked a nice winapi – Best way to do non-flickering, segmented graphics updates in Delphi question on StackOverflow.

Though the question is marked Delphi, the boundaries and solution very generic, and apply to any graphics library or GUI you develop: Windows, Mac, iOS, et cetera:

  • Avoid double buffering when using GUI connections
  • Draw only what you need
  • Avoid redrawing whenever possible (for instance by letting the OS perform scrolling for you)
–jeroen

Posted in .NET, Delphi, Development, Software Development, xCode/Mac/iPad/iPhone/iOS/cocoa | 2 Comments »

Weaving: Source code, IL, ByteCode, Native

Posted by jpluimers on 2011/06/28

Weaving extends your program adding new functionality.

It can be at different levels for difference purposes (AOP, Debugging, Automated Testing, etc).

This .net – What is IL Weaving? question on StackOverflow contains a few pointers to interesting reading material.

–jeroen

Posted in .NET, Debugging, Delphi, Development, Software Development | Leave a Comment »

StackOverflow C# question: Slight confusion over reference types and value types in the C# spec

Posted by jpluimers on 2011/06/23

Recently there was a nice Slight confusion over reference types and value types in the C# spec on StackOverflow.

Summary:

When structs are value types, but interfaces are reference types, how can a struct implement an interface and still be a value type?

The answer is boxing: when a reference to a struct is needed, a reference object is automatically created, and the value of the struct is box-wrapped into it.

This automatic boxing is really nice, but be aware that when frequently doing this, it can have a huge performance impact.

Thanks Abhina Basu for blogging about boxing structs having interfaces, and the many volunteers on StackOverflow explaining about boxing.

–jeroen

Posted in .NET, C#, Development | Leave a Comment »

.NET WPF Databinding to Collection Properties » Danny Thorpe

Posted by jpluimers on 2011/06/22

Danny Thorpe recently wrote a very nice post on via Databinding Collection Properties in WPF that sometimes fail without warning.

The short summary is that this fails without warning when binding to properties that do not explicitly implement the IList interface, for instance when binding to a collection that supports only IEnumerable (because of yield return) or IList<T> (for instance when binding to a Dictionary<TKey, TValue>.Values, which implements IList<T>, but not IList).

Thanks Danny for blogging about this (he explains it way better than I can), and putting a warning that the workaround Dictionary<TKey, TValue>.Values.ToList() potentially can have a big impact on memory consumption.

Life would be so much easier if WPF could bind to IEnumerable or IList<T> :)

–jeroen

via: Databinding Collection Properties » Danny Thorpe.

Posted in .NET, Development, Software Development, WPF | 2 Comments »

c# – Generics and nullable type – Stack Overflow

Posted by jpluimers on 2011/06/14

A while ago, I needed some generic way of parsing data that could result instancef of both regular ordinal and nullable ordinal types.

Luckily there was a nice question about this on StackOverflow, of which I liked this answer (source code below) much more than the accepted answer: concise, elegant, period.

    public static T? Parse(this string text) where T: struct
    {
        object o = null;
        try
        {
            var ttype = typeof(T);
            if (ttype.IsEnum)
            {
                T n = default(T);
                if (Enum.TryParse(text, true, out n))
                    return n;
            }
            else
                o = Convert.ChangeType(text, ttype);
        }
        catch { }

        if (o == null)
            return new Nullable();

        return new Nullable((T)o);
    }

–jeroen

Posted in .NET, C#, C# 2.0, C# 3.0, C# 4.0, Development, Software Development | 1 Comment »

Delphi Win32 talking to .net – Different WSDL ASMX,WCF web-services – Stack Overflow

Posted by jpluimers on 2011/05/31

An interesting question on Stackoverflow.com: .net – Different WSDL ASMX,WCF web-services – Stack Overflow.

The answer is simple when you know it: flatten the WSDL that comes from WCF.

Note that Delphi Win32 is not the only client having these issues, as Elton Stoneman shows on his blog and the WCFExtras toolkit for WCF that allows for single WSDL export.

–jeroen

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