Archives

Archives / 2005
  • xp_sprintf: Important Safety Tip

    While doing some T-SQL coding today against a SQL2K server I noticed a very frustrating issue: The xp_sprintf system stored procedure fails if the variable you send it to receive the formatted string is not long enough to hold the entire string. However, it doesn't tell you it fails. It just sets the string to a NULL and returns zero (Success). The @@ERROR server variable is also zero.

  • You call that support?

    Why does this happen? I spend at least two hours reducing a problem in some company's reporting engine down to a very manageable piece of sample code that can be run by anyone -- no database connection required (everything is done from XML datasets that are embedded in the sample). It's easy. It reproduces the problem. It's a great starting point for tech support.

  • Take the GANG Survey!

    If you're in the Detroit, Michigan area, please take a moment and fill out a survey created by our local .NET user group. We (the board members of GANG) want to know what's working, what isn't working and any ideas you may have for change. Even if you don't currently attend the meetings, please fill the survey out and let us know why. Thanks!

  • September GANG Meeting

    If you're in the southeast Michigan area you'll want to make sure you come to the GANG meeting on September 21st. Not only do we have a couple of great speakers (Josh Holmes and Tim Landgrave) talking about a hot topic (web services), but we've got a free copy of Visual Studio 2003 we're giving away! Everyone that shows up gets a chance to win. And if you bring a friend you'll double your chances! Don't miss it.

  • Value types and Nothing

    A while back I blogged about some interesting IL generated by the VB.NET compiler. Basically, VB.NET allows you to set a value type to Nothing and the resulting IL seems overkill. Today, while I was googling for something .NET related I found Dan McKinley's blog. Earlier this year he had blogged about this very same thing and got a comment from Paul Vick (Technical Lead on VB.NET @ Microsoft) that this was actually a bug in the VB.NET compiler that has been fixed in VB 2005. Good to know!

  • Log4net's new TelnetAppender

    The recently released 1.2.9-beta of log4net contains a new appender -- TelnetAppender. This appender acts like a telnet server and allows telnet clients to connect to it and monitor log4net's trace messages. I've only used log4net 1.2.8 but the TelnetAppender sounded pretty neat so I had to try it out. Here's a quick sample app I did. Note the DOMConfigurator has been deprecated and I'm now using the XmlConfigurator:

  • IsNothing? Definitely!

    While reviewing some existing code at my new job I noticed that they use the VB.NET IsNothing() function instead of using the "Is Nothing" syntax. I didn't even know there was an "IsNothing" function so I compiled some code and checked it out with ILDASM. Here's what I compiled:

  • Setting value types to Nothing?

    Why in the world does VB.NET let you assign 'Nothing' to a value type? It's not that big of a deal unless you've got a structure. Consider this simple structure:

  • What about NumLock?

    One of the nice things about the XP logon is that when you're in the password field, a balloon tip will pop up if your CAPS LOCK key is on to remind you that you may not be typing what you think you're typing. However, since most laptops don't have a separate numeric keypad, the NumLock key can be just as frustrating. When will we get a balloon tip for that?

  • Time to move on.

    It's time to move on to new opportunities. My current employer has accepted my two week notice. I've got a little bit of coding and documentation to finish up. This will probably be the last bit of VB6 coding I do for the foreseeable future. It's been a fun 4 1/2 years and I've worked with a great bunch of people -- including one of the best architects I've had the pleasure to work with.

  • A clean fade out

    Someone at our local .NET user group asked me about a problem he was having closing a form. He was using a for/next loop to gradually reduce the Opacity property until it hit zero and then he could close his app. He was using Thread.Sleep() inside the loop to control its speed.

  • USB ports and .NET

    I've seen the question a number of times in the newsgroups: Can you access the USB ports with .NET? Usually it's "No", but digging around tonight I found that developer of SharpDevelop has created a .NET Library for USB port access called #usblib (SharpUSBLib).

  • VSM arrives in "style"?

    The latest issue of Visual Studio Magazine arrived in a special envelope from the post office. A pre-printed message on the envelope apologized for the delay in getting the item to me. It had encountered some "problems" en route to me. I opened the enveloped and discovered a large chunk of the magazine missing:

  • VB.NET Shares a little too much

    A thread today on using the System.Diagnostics.Process class highlights one of the more confusing aspects of VB.NET (or VS.NET depending on how you want to look at it). Intelliense will list Shared (static in C#) members when showing members on an instance variable. Take the following sample code:

  • Do you "organize" your 'using' statements?

    More and more I find myself "grouping" my using statements ("Imports" in VB.NET). For example, I now try and do Microsoft framework namespaces first, then namespaces for DLL's developed at my employer and finally third party namespaces. Something like this:

  • Timing is everything

    I was doing some code reviews today. The particular project I was reviewing was doing COM-interop so one of the things I looked for was to make sure that any COM objects created were wrapped in a try/catch/finally block and those objects were properly released with Marshal.ReleaseComObject in the finally block.

  • IL Editor

    Want the most from your .NET applications? You want absolute control at the IL level? Then why not develop directly in IL... :)

  • Virtual PC Network Problems

    I picked up an extra 512MB of RAM a couple of weeks ago to bring my development system up to 1GB of RAM. Now I've got a decent amount to play around with VS 2005 via Virtual PC. Last night, I created a VPC image with Windows Server 2003 but couldn't get it to talk to my network. I played around with this for close to an hour until I remembered that I have MAC Address filtering enabled on my DLink router. Only the MAC addresses I list can talk to the router. Once I added the MAC address from the VPC image to the list I was all set. Hopefully this will save someone else an hour! :)

  • Running in the IDE?

    I was reviewing some old code samples I had laying around (cleaning off the hard drive so my backup set will fit onto a single 4GB DVD) and came across one about determing if you're running inside the VS.NET IDE. Well, VS.NET is a debugger, so you can use System.Diagnostics.Debugger.IsAttached.

  • VB6, ByRef, ByVal and Interop

    While COM Interop may have some drawbacks, many times it is a necessary step (budget constraints, time constraints, etc...). If you're currently developing VB6 objects that may some day be used in .NET via interop then now is the time to get your ByRef's and ByVal's cleared up. It will make your interop experience much more enjoyable.

  • Static Cling? No, Static Wierdness.

    I thought this was a little odd. As you may or may not know, static (Shared in VB.NET) members are not inherited. Since static members are members of the class, not an instance of the class, this makes sense. When you create a subclass, you're creating a new class so you don't get the static methods.

  • Oracle and Blobs

    More fun with Oracle! I was reading an Oracle table that contained a "LONG RAW" field. You're supposed to be able to get at those types with the GetBytes method. According to the MSDN documentation for IDataRecord.GetBytes: