Brendan Enrick

Daily Software Development

Old Blog Favorites

I am somewhat partial to a few of the posts from my previous blog. For some of these posts, I just like the post, some the content about which the post was written, and some were just popular posts.

Installing SQL Server Management Studio with SQL Server: My most popular post is one written about a painful experience installing SQL Server's client tools. Sadly the popular post is out of date. My first post about the topic I found a solution that worked and managed to install the software. I late found out that there was a better way and I updated the post. The problem is that Google continued to send traffic to the old one. For my blog it was a pretty popular post. it has had over 25,000 views.

The original version - Installing SQL Server Management Studio with SQL Server

The current version - SQL Server Client Tools Installation

Visible Whitespace in Visual Studio: Another post written about a traumatic experience was when I accidentally used a keyboard shortcut and enabled visible white space. It caused a blue dot to show for every space character in visual studio. Wow was it hard to read my code with that on. Well I Googled for it, and at the time I didn't receive any results. There are some now my post is one of them. I also didn't notice the option to turn it off. I used an algorithm I like to call brute force to figure out the keyboard shortcut I typed. It was Ctrl + E + S. Comments let me know of a bunch of other ways to solve the problem for different configurations and versions of Visual Studio.

Visible Whitespace in Visual Studio

Return Within a C# Using Statement: IDisposable objects are nice to work with. I prefer not dealing with external resources, which is generally what you're doing with disposable objects, but having this interface makes it a little bit nicer. I wrote a post telling people it was safe to return from within the using statement, because the using statement will make sure that the object is disposed. In the lifetime of the post only one person actually challenged me on it and asked me to provide code showing that what I said is true. I of course responded to that comment and then posted a response on this blog. My response includes sample code showing that using statements make sure that the object is disposed.

If you like the second post make sure you thank Lambros Kaliakatsos for commenting on the first one.

The original post - Return Within a C# using Statement

The follow up including sample code - Returning From Inside a Using Statement

Performance with DropDownLists and ViewState: One thing that it seems a lot of ASP.NET developers still don't understand very well is ViewState. Page lifecycle stuff seems to really be fueling the MVC craze these days. I wrote a post talking about how ViewState can hurt the performance of your applications if you let it get out of hand. The example I used is the drop down list, but it can certainly get a bit crazy from grids, repeaters, etc. I wrote an article basically saying that you should try to avoid ViewState if you're going to have too much of it. I later followed up with a post about how to use a DropDownList without ViewState. Some people are concerned that you will not be able to use the SelectedValue property, but you can if you wire it up correctly. It is all about understanding that painful Page Lifecycle.

Performance with DropDownLists and ViewState

Using a DropDownList without ViewState

There are plenty of other posts I like in there, but I think I've bored my readers enough for one day. I've got a couple of posts lined up which should be a little bit more interesting than this one, so keep reading. As always, have a great day.

Time for Being Thankful

In the United States we are currently celebrating Thanksgiving Day. Everyone have a happy Thanksgiving. It is time for being thankful for all the wonderful things in our lives.

for (var thingThankfulFor in thingsThanksfulFor)
{
    Say("I am thankful for " + thingThankfulFor.Name);
}

HAPPY THANKSGIVING EVERYONE!

Updating RSS Feed Location

I have set up a new feed on feedburner. I am hoping most of my readers will be willing to switch to the new RSS feed. http://feeds.feedburner.com/BrendanEnrick

Please update your subscription to http://feeds.feedburner.com/BrendanEnrick

Looking forward to posting more and better content since this blog should be easier for me to use.

For the time being the old RSS feed location will work just fine, but I'd rather consolidate everyone into one nice more generic rss feed.

foreach (Reader blogReader in myBlog.Readers)
{
    Say("Thank you for reading!");
}

Storing and Retrieving Serialized Data with Azure Blob Storage

On a project I am currently working, we have some normalized data which we need all instances of our Worker Role to have access to. This data when denormalized for the table structure we use requires us to take each row and turn it into about 50,000 rows. Because of this we obviously don't want to denormalize it and store it in Azure's table storage. We eventually will be doing this, but we need to work with it before denormalizing it.

The plan we came up with is to serialize the data and store it as a blob in Azure storage. We tried it a few different ways running into snags in what seemed to be all directions. I just figured out how to get it to work. Finally.

First we need to check and see if the blob exists, and if it does we need to obtain the data from it.

var blob = BlobStorage.Create(
        StorageAccountInfo.GetDefaultBlobStorageAccountFromConfiguration()).
        GetBlobContainer("myblobcontainer");
 
var encoding = new ASCIIEncoding();
 
if (blob.DoesBlobExist("myblob"))
{
    Stream stream = new MemoryStream();
    var contents = new BlobContents(stream);
    blob.GetBlob("myblob", contents, false );
    
    string myXml = encoding.GetString(contents.AsBytes());
    
    StringReader stringReader = new StringReader(myXml);
    var reader = new XmlTextReader(stringReader);
 
    var deserializer = new XmlSerializer(typeof(List<MyObject>));
    var myDataObjects = (List<MyObject>)deserializer.Deserialize(reader);
}

Second we need to work with the data.

// Do a whole bunch of work here.
// This stuff is really important.
// Did you really just read a block
// of comments in a blog?
 
// I am being honest when I say that
// these blocks of comments are
// not really needed at all, but
// wasn't it fun reading this pointless
// block?

Third we put the data back with updates

var serializer = new XmlSerializer(typeof(List<MyObject>));
var stringBuilder = new StringBuilder();
XmlWriter writer = XmlWriter.Create(stringBuilder);
serializer.Serialize(writer, myDataObjects);
 
byte[] theseBytes = encoding.GetBytes(stringBuilder.ToString());
 
blob.CreateBlob(
       new BlobProperties("myblob") { ContentType = "text/xml" },
       new BlobContents(theseBytes),
       true);

Hooray! We're now able to serialize to Azure Blobs.

First Post?

In classic forum style this is not the first post, but it is close. Just trying to get some content to take up some space on the front page of my new blog. Yes, you heard correctly. NEW BLOG! WOOHOO!!!

Blog Moving Here

Ladies, gentlemen, boys, girls, and anyone who doesn't fit in any of those categories this includes, ruffians, riffraff, hooligans, and probably some other people listen up. I have wonderful news to announce. I am finally moving my blog off of aspadvice.com, the site which has graciously given my blog a home for over two years now.

I welcome everyone to this new experience known for now as...... Brendan Enrick's Blog.

What does this mean to you? Well it means that if you ever visit my blog and read a post you'll have a nice look and feel. It also means better integration for me using Windows Live Writer.

Will any of what you've said above change? Yes, of course it will change. Doesn't everything? Perhaps I will switch to another program for writing my blogs. Until that day comes though who knows.

All crazed lunacy aside, this is my new blog. I hope everyone likes it and enjoys reading it.

Thank you and good night........ um....... I mean morning. It is after all 9:25 AM here right now.

Blogging Code Snippets Using Windows Live Writer

So obviously anyone wanting to write technical blog posts will eventually require code snippets on the posts. Posting code is not very difficult. The basic part is just that you want the browser to know that your text is code and it should not apply standard html formatting to it; wrapping lines, etc. The key ingredient to this is the html tag pre. It tells the browser that the following is special. It really just means that the inner text of the tag is preformatted, and that the browser should do nothing but display the text. Very useful for displaying code snippets. Especially if the snippets are html snippets. Wouldn't it be bad if the browser rendered the code you were trying to show people.

So great we have preformatted text, but it still doesn't look nice at all. Well I could sit there and color the snippets and spend time formatting it nicely, but I use Windows Live Writer. Great tool. I blogged about why I like Windows Live Writer in the past, and the add-ins I am about to mention simply add to my admiration of this tool. There are a few great code snippet inserting tools. Which let you choose a language and it will format the code nicely including some coloring for you. Some will give you containers and fancy alternating lines. I've settled on no container without lines. It seems to work well enough for my purposes. Not too fancy, but still readable enough to allow the code to be useful to others.

I hope that is useful to people out there. I highly recommend these code snippet inserting tools. Also I recommend Windows Live Writer and the plug-ins for it. There are a lot of useful tools for this application. (Yes, I am using Windows Live Writer for this message.)

Happy blogging!

Five Things you did not know about me

Like everyone else, I’ve now been tagged into this game. Steve Smith tagged me so now I will tell you five things about me that you may not know.

1. I have lived in one city my entire life. I’ve been living in Kent, Ohio since I was born, and I have yet to move elsewhere. I’ve lived in 3 homes in Kent. I am currently attending Kent State University, so am still not out of Kent. Not sure when I will leave Kent, but I doubt I will be living here for too many more years.

2. I’ve been a world traveler since I was 10 years old. This is when my family started going on trips. Though my travels have been much more extensive than most people of my age, I have not seen nearly everything I wish to in my life. I have been to Venezuela twice, most islands in the Caribbean, Mexico a few times, Canada more times than I can remember, Hawaii once, England twice, France twice, Corsica once, once to Italy, once to Spain, and I’ve probably forgotten something. Sadly I have not yet been to Germany. I wish to see much more though, and hope to see many places in Africa, Asia, and Australia.

3. I, like Steve Smith, am a gamer. As can be seen by the title of my blog I am obviously some type of a gamer. I enjoy playing Dungeons and Dragons. Yes, I am aware that it is the stereotypical nerd game. It is not the only game that I play though. I enjoy making up my own games. These games have their own worlds and own systems for play. I enjoy playing them a great deal. I also enjoy playing card games, board games, and video games. Most of my games are console games, but I also play a lot of PC games. The board games I play are classics as well as lesser known games. One of my favorites since I was a child is called Solarquest.

4. After number 3 this one becomes more obvious. I would like to eventually work in some type of game design. I think it would be great fun. I might be able to get into video game development with help from the degree in Computer Science I am about to earn from Kent State University. I know many people who would like to work on games. This semester I will be taking a class about designing and building game engines. I hope it is a fun class.

5. Most people don’t know that while I think this five things idea is kind of cool. I have this notion that I am merely propagating a chain letter farther along. I don’t know if others have gotten this same feeling, but it would seem to me that this, while interesting, at its roots is an attempt to see how far the chain lett……. the five things blog will go.

So now I must search for bloggers who have yet to list five things or be tagged. Such a cruel fate. Here is a group of people I have yet to see five things from, and whom I know little about. I apologize in advance if these people have been tagged already or do not want to play the game.

Alessandro Gallo ( Garbin )
Joydip Kanjilal
Ian Lipsky
David Walker
Mo Meng