Tuesday, March 30, 2010

Web.config files and legacy products

I've been working with a CMS product called Ektron CMS400.net for the last couple months. Well that's a lie. I haven't been using it the entire time. A lot of the time has been spent just getting the product up and running in our environment. We will save all that for maybe another post.

This post is about upgrading legacy product web.config files to work with newer technologies. This particular instance revolves around the ability to use "var" and extension methods available in .Net 3.5 in the actual inline code of an aspx page.

The scenario is that I wanted to create a wrapper extension method to string that I would pass in a string tag name and it would wrap the string with the appropriate tag based on that name. I did this and everything works when in cs files. That changed when it came to consuming the same extension method inline.

The following piece of code threw a "'System.string' does not contain a definition for 'WrapWithTag'" error:


I then did some quick Googling to find out what I could do to fix this, or even if I could. AHA! I found it. It was due to the missing lines in the web.config file. Below you will see the difference between the standard 2.0 Web.config file to a 3.5 version. (The Web.config file I was working with was a monstrosity in comparison)

.Net 2.0 Standard Web.config file:


.Net 3.5 Standard Web.config file:


The actual piece that I needed in my Web.config file was:


This piece ensured that the ASP.Net compiler would run .Net 3.5 instead of 2.0.

Wednesday, March 24, 2010

snipt! Where were you when I first started posting code online!

I am sure there are many tools out there to allow embedding code hosted somewhere else with cool color coding. The one I recently came across is Snipt. It is pretty simple and easy to use. If you have any others that work just as nice please comment!

Sunday, March 14, 2010

MonoTouch...A .NET (C#) developers dream for building iPhone apps

I have finally got the Mac all up and running how I would like it. I think there will be a lot of changes as soon as I really start using this thing. My next steps were to get the iPhone SDK, Mono Framework, and MonoTouch installed so that I could get to making iPhone apps.

You will need to do a few things in order to start developing with MonoTouch
To get started with a simple "Hello World" application. See Getting started with MonoTouch on CodeSnack.

Friday, March 5, 2010

Got a mac...but it isn't mine...

I have acquired a MacBook Pro from some friends so that I can start dabbling into the iPhone dev market. I have used Mac's in the past, but not as a full time system.

Now that I have this machine, I am trying to set it up the make it as my main machine at work. The first step was HOW THE EFF do I RDP into a PC machine. The answer is quite simple, CoRD. CoRD is an RDP application that seems to be recommended as one of the better utilities to RDP.

This was the first step in getting acquainted with my Mac.

More to come...

Thursday, March 4, 2010

Linq to Xml Stress!

So it has been a while since I have written anything, but the issue I just over came was enough to write home about.

My task was to parse some Xml into an object. We all love using the new ways of doing things. I chose to use Linq to Xml. Now I have been using this method for some time now, making life parsing Xml quick and easy.

The problem that I came across was if you lack the control of what that Xml will look like and it is not properly Html Encoded. Linq to Xml does not include the InnerXml property that was once available on XmlElement.

After looking through every available method and property available on the XElement, I thought my life was over and was going to be forced to hack out a solution. The latter is still somewhat true, but the hack has been nicely implemented using an extension method called InnerText.

Below is the code used to generate the InnerText solution, this being the fastest of other solutions such as using a StringBuilder