Thursday, January 05, 2006

My post earlier today referred to the FileHelpers library by Marcos Meli.

Wow, do I wish I had known about this earlier. This thing is great! With a few easy attributes, you can use a business object as a layout for fixed-length files! Okay, I guess an example would help. Here's some VB code I whipped up to test this library out.

Imports FileHelpers

Public Class MainForm
    Private Sub MainForm_Load(ByVal sender As Object, _
        ByVal e As System.EventArgs) Handles Me.Load

        Dim engine As New FileHelperEngine(GetType(Record))

        Dim records() As Record = _
            DirectCast(engine.ReadString("123456789  2005-01-01"), _
            Record())

        Debugger.Break()

        Dim res As String = engine.WriteString(records)

        Debugger.Break()
    End Sub
End
Class

<FixedLengthRecord()> _
Public
Class Record
    <FieldFixedLength(11)> _
    Public BillNumber As String

    <FieldFixedLength(10), _
    FieldConverter(ConverterKind.Date, "yyyy-MM-dd")> _
    Public BillDate As DateTime
End
Class

At each Debugger.Break line, I checked my values and this thing is great. records(0).BillNumber is "123456789  " and records(0).BillDate is a converted DateTime set to 1/1/2005.

If you deal with fixed-length or delimited files on a regular basis, this library might be a great option for you.

Thanks Marcos!

UPDATE: Version 1.3.1 was released recently, so I have updated my example code to use the new ReadString and WriteString methods.

posted on Thursday, January 05, 2006 1:53:42 PM (Central Standard Time, UTC-06:00)  #    Comments [1]

By way of Larkware, I came across the FileHelpers library written by Marcos Meli. It looks like a great solution for dealing with delimited or fixed length file formats. The majority of the output formats from our backend systems at work are fixed length file formats, which can be a pain to parse. I had actually written a library to parse them and reference portions of each line by name (sort of a named index to portions of a line), but this looks like a much cleaner approach. I'll dig into this some more and post my thoughts on it.

posted on Thursday, January 05, 2006 1:21:07 PM (Central Standard Time, UTC-06:00)  #    Comments [0]
 Wednesday, January 04, 2006

Over a year ago, I built a new PC from the ground up. This wasn't my first PC to build mind you. I hand-picked all of the parts and had a great time putting it together. If you've ever built a PC, you know the feeling of hitting the power button after hooking the final jumpers and hearing that familiar whirr as the PC boots up. Boy, is it a scare when it doesn't do that! That's what happened with this PC... absolutely nothing. Long story short, I got the PC to come on finally, but everytime I shut it down, it wouldn't come back on without my resetting the CMOS by using a jumper on the motherboard. I tried replacing the CMOS battery, changing out the memory... everything. I finally found some people online in a hardware forum with a similar problem. Their solution? RMA. *sigh* What was MY solution? Get a Dell. Okay, okay, I'll admit it. I chickened out. I just didn't want to get burned again. I'm still using that Dell, too.

Flash forward to the present. I wanted to build a PC for my wife and I still had that motherboard sitting around. I ended up RMA'ing it and I got a replacement back. I hooked it all up a few nights ago and, miraculously, it worked! I had a few strange lock-ups, but they seemed to stop. Tonight, it won't turn on. I took the case off and reset the CMOS to see if anything would happen. Something did happen, but only for a second. I heard the whirr for about a second and then silence. I would guess a short, but I don't know. Building a PC is a lot of fun, but it can be great source of frustration when it doesn't work.

My recommendation for building PC's (ha, like you'll listen to me now) is do a Google search on some of the hardware you're interested in, but put words in there like "problem" or "this piece of crap won't work" or something. If you find a lot of results, check them. It can save you some stress later on.

posted on Wednesday, January 04, 2006 10:06:58 PM (Central Standard Time, UTC-06:00)  #    Comments [0]

I ran into that error today while attempting to install Infragistics NetAdvantage 2005. I'm not exactly sure about why the error occurred, but I was able to find a fix here (via this MSDN forum thread). Some of the other solutions appear to be reinstalling VS2005, but luckily, the registry fixes from Chetan's blog worked fine.

posted on Wednesday, January 04, 2006 4:47:57 PM (Central Standard Time, UTC-06:00)  #    Comments [0]

Has anyone noticed a new menu item under the Build menu in Visual Studio 2005? There is a Clean Solution item that will remove all of the compiled binaries that live under your bin folder. It is relatively similar to Clean Sources Plus, except that it keeps the folders.

Note: I'm not sure if it shows up in every VS configuration. I'm using the default view (see Tools -> Import and Export Settings).

posted on Wednesday, January 04, 2006 1:11:43 PM (Central Standard Time, UTC-06:00)  #    Comments [1]
 Tuesday, January 03, 2006

I ran into a strange situation this afternoon with visual inheritance and threading. I've created a master form for my area at work so that we can have a common menu in all of our applications. It also provides a public readonly property that has information about the currently logged on user. The user's information is pulled using a BackgroundWorker so that the form can display promptly.

Here's the situation, a few days ago, I added a ManualResetEvent so that, if access to the User property was attempted before the thread completed, a NullReferenceException wouldn't occur. I had already put code in so that the initial loading of the user's information would not fire in design mode. The problem that began happening was that, every time I tried to open a form that inherited from my master form, Visual Studio would lock up. I pulled up a second devenv to see where the hanging was occurring and, sure enough, it was sitting on my ManualResetEvent inside my user property. Why in the world was the designer accessing my user property?

The more astute (or experienced) of you will realize that I hadn't marked my property with that oh so important System.ComponentModel.Browsable(False) attribute! The designer was accessing the property so that it could display it in the Properties Window!

Let me be an example of what perils can occur when you play with visual inheritance and the designer!

posted on Tuesday, January 03, 2006 2:21:26 PM (Central Standard Time, UTC-06:00)  #    Comments [0]
 Monday, January 02, 2006

I'm finally a part of the blogosphere. I'll plan on this being a place to post primarily .NET related news as well as tools or other technical related news. We'll see what happens.

posted on Monday, January 02, 2006 10:59:43 PM (Central Standard Time, UTC-06:00)  #    Comments [1]