Reflection IT Blog

Benieuwd naar de laatste ontwikkelingen rondom software ontwikkeling en Reflection IT? Onze slimme koppen delen regelmatig hun kennis en ervaring. Zo weet jij wat er speelt!

Fons Sonnemans Blog posts

Binary Compatiblity

22-Jul-2005

Microsoft has released a free LibCheck tool that allows you to compare two versions of an assembly, and determine the differences. The tool reports the differences as a combination of 'removed' and 'added' APIs. The tool is limited to looking only at APIs (i.e, it can't check for behavioral changes), and only compares public differences, or changes which are deemed to be 'breaking'. The tool can be used to quickly determine what has changed between one version of your assembly and another, and can help ensure that you won't introduce any breaking changes to clients of your assembly. Instructions and intended use of the tool are described in the 'libcheck tool specification' document with the zip file.

This was a feature I always was missing. VB6 had this, VS.NET didn't. Thanks MS.

AsyncHelper for VB.NET

21-Apr-2005

I received a mail today from Rolf Gasber asking me whether I could help him with a VB.NET version of the AsyncHelper which I used in an earlier post. Here it is:

Public

Class AsyncHelper

    Private Delegate Sub DynamicInvokeShimProc( ByVal d As [Delegate], _
                                
ByVal args() As Object )

    Private Shared _dynamicInvokeShim As _
                                 
New DynamicInvokeShimProc( AddressOf DynamicInvokeShim)

    Private Shared _dynamicInvokeDone As _
                                  
New AsyncCallback( AddressOf DynamicInvokeDone)

    Public Shared Sub FireAndForget( ByVal d As [Delegate], _
                                 
ByVal ParamArray args() As Object )
        _dynamicInvokeShim.BeginInvoke(d, args,
AddressOf _
                                
 DynamicInvokeDone, Nothing )
    End Sub

    Private Shared Sub DynamicInvokeShim( ByVal d As [Delegate], _
                                  
ByVal args() As Object )
       d.DynamicInvoke(args)
    End Sub

    Private Shared Sub DynamicInvokeDone( ByVal ar As IAsyncResult)
      
_dynamicInvokeShim.EndInvoke(ar)
    End Sub

End

Class

Microsoft has put my 'Dual List' .NET Magazine article online!

09-Apr-2005

Microsoft has put my Visueel programmeren met .NET: Dual List Control article online. It is published in the .NET Magazine #8 and it is free for Dutch developers.
They didn't publish the sourcecode (yet) but you can download it from my own site. The aricle is in Dutch. You can find an (old) English version of this article here. An even more advanced implementation that also supports Drag & Drop can be found here.

WaitCursor

10-Feb-2005

For a long time I thought that I only had to set the Cursor.Current to a WaitCursor before a long running operation, the .NET runtime would reset it back to the Default cursor. Turns out that this is only true when the mouse is moved. Bummer.

// Cursor.Current are automatically reset to Default when the
// mouse is moved and the application is idle!
Cursor.Current = Cursors.WaitCursor;

The solution for this problem is very easy. I created a helper class called WaitCursor which set the Cursor.Current and restores it to the original value when it it disposed.

public sealed class WaitCursor : IDisposable {   &nbsp   &nbsp   &nbsp   &nbsp
   &nbspprivate Cursor _prev;

   &nbsppublic WaitCursor(){
   &nbsp   &nbsp_prev= Cursor.Current;
   &nbsp   &nbspCursor.Current = Cursors.WaitCursor;
   &nbsp}

   &nbsppublicvoid Dispose(){
   &nbsp   &nbspCursor.Current =_prev;
   &nbsp}
}

I create the instance of the WairCursor class inside a using statement. This will automatically call the Dispose() method when it goes out of scope.

Micro-ISV

11-Jan-2005

Microsoft has invented a new name Micro-ISV, which are software companies that are comprised of only one person. So, I'm a Micro-ISV. Planning to launch my product this year. I hope to succeed.

Dispose Modal WinForm Dialogs

12-Dec-2004

There is a difference in disposing Modal and Non-Modal forms. In a training I gave last week I noticed that even experienced developers didn't know that Modal Dialogs don't dispose automatically, Non-Modal do.

private void buttonShowNonModalForm ( object sender , System.EventArgs e){
   &nbspnew TestForm().Show();
}

privatevoidbuttonShowModalDialog(objectsender, System.EventArgs e){
   &nbspnew Form2().ShowDialog();
}

The solution to this problem is very simple by creating the Form instance within a using block. This will dispose the Form when it is closed.

private void buttonShowModalDialog ( object sender , System.EventArgs e){
   &nbspusing(TestForm f =new TestForm()){
   &nbsp   &nbspf.ShowDialog();
   &nbsp}
}

An alternative solution uses a try/finnaly. Personally I prefer the previous, it is easier to read and write.

C# HandleWhiteSpace Add-In

23-Sep-2004

The C# code editor in Visual Studio.NET 2003 does not handle whitespaces automatically like the VB.NET code editor does. This Add-In solves this problem by adding the 'Handle WhiteSpace' menu option to the Visual Studio.NET 2003 Tools menu. This option formats the C# code of the active code editor. This includes:

  • Space before:  method declaration parentheses, method call parentheses, statement parentheses, braces and brackets
  • Space after: comma and semicolon
  • Space around: operators
  • Double space

DualList Drag & Drop Component

16-Sep-2004

I have written an article two years ago with the title 'WinForm DualList Component'. In this article I mentioned the desire to extend the DualList component with Drag & Drop support. Finally it's done. Not by extending the original DualList component but by creating an new DualListDragDrop component (reason: cohesion).

Programming Drag & Drop (D&D) between listboxes is quite difficult. It requires at least 60 lines of code for every two listboxes. Therefore not many application support D&D. This component eliminates need of writing the code. You only have to set properties on it. Making it easy to support D&D in your applications.

Get in touch

Met dit formulier kunt u informatie over een In-Company of Small-Group training aanvragen. U kunt in het bericht aangeven welke training u wilt, voor hoeveel personen, wanneer deze verzorgd moet worden en op welke locatie. Wij nemen vervolgens contact met u op.

U kunt ons ook bereiken via telefoonnummer +31 (0)493-688810 of per mail training@reflectionit.nl.