Dan Byström’s Bwain

Blog without an interesting name

Archive for May, 2004

A new beginning

Posted by Dan Byström on May 24, 2004

I’ve been spending the last months writing my first .NET projects using C# (which Jimmy Nilsson talked me into using). Being an old C/C++ programmer I like the C# syntax 10,000 times better than the VB syntax and since they share the same IDE I can’t see any reason to stick with VB any more. Actually, I used to say “I love the Visual part but dislike the Basic part in VB”. With C# I still have the Visual and the Basic is gone.

Anyway, I have spent over 10 years sharpening my VB skills to become as productive as possible. With the advent of .NET, 10 years worth of knowledge has to be updated, getting to know all that’s in the .NET documentation, and more importantly, what’s not in the documentation.

For example, I’ve just learnt that one possible cause of the error “An unhandled exception of type ‘System.ArgumentException’ occurred in system.windows.forms.dll Additional information: Invalid parameter used.” thrown from a thread so that it can’t be catched, might be that a disposed image is, by accident, displayed in a picturebox control. Not very obvious. I also learnt that the .NET Framework, when loading a bitmap from a file, for some reason keeps the file locked until the image/bitmap gets disposed. I still can’t figure out why, but it took me half an hour to realize that this was true. 😦

After plowing through the docs, I still wonder if there is an equivalent to the VB Val function in the Framework – a function that doesn’t throw an error when a non-numerical character is encountered.

My #1 favourite thing so far with VS.NET is the seamless integration between languages. I was in the need of calling a Win32 DLL with a vast number of functions and structures declared in C++ .h files as well as linkage information in .lib-files. Instead of converting them to C#, I just added a C++ project to my C# solution and wrote a wrapper in unmanaged C++! Totally seamless integration in the IDE and even in the debugger! Compare that to writing a DLL or OCX in VC++ 6 and debugging it while using it from VB6 code! I like it, I like, I like it!!!

Posted in Programming | Leave a Comment »