Thursday 29 January 2009

Best way to write XML in C#

This is my opinion the way to create XML within c# - LINQ to XML:

var root =

new XElement("content",

new XAttribute("id", node.Id),

new XAttribute("url", node.NiceUrl),

new XAttribute("title", property != null ? property.Value : node.Name)

);

Thursday 15 January 2009

XSLT and .NET user control breaks in IE7

I was getting random XHTML in my IE7 page due to me HAVE an XSLT above my .NET user control. A change in the XSLT solved this issue:

xsl:output method="html" declaration="yes"


Instead of

xsl:output method="xml" declaration="yes" />

Wednesday 14 January 2009

Changing the routing table XP

This is a neat tick shown to me by Alex Norcliffe.

Environment: My laptop has to connect to SVN via my wireless connection while all other requests can go through the local LAN connect on my laptop. I am using Tortoise SVN to access my SVN repository. The LAN connects through a proxy to the Internet so I thought changing the Tortoise SVN proxy settings would allow me to just use the LAN connection, but unfortunatley the proxy doesn't allow SVN requests.

Solution:
So using both connections (Wireless and LAN) Alex changed the routing table so only SVN request get redirect via the wireless. This is how he did it:

1. Command prompt
2. Type: route print (This will bring up the routing table list)
3. Ping the SVN URL to get the IP address
4. Add a new route entry by typing: route add SVN_IP mask 255.255.255.255 WIRELESS_IP
5. Test by typing: tracert SVN URL

Genius short-hand way of concatenating rows into single string in SQL

DECLARE @ValueList NVARCHAR(MAX)

SELECT @ValueList = COALESCE( @ValueList + ', ' + ColumnAlias, ColumnAlias, @ValueList)

FROM MyTable

PRINT @ValueList

Thanks to Alex Norcliffe for this!

Friday 9 January 2009

Could not resolve assembly reference

I am using SVN with Visual Studio 2008 and updated to the latest version, then tried to rebuild. I got this message:

Unable to reslove assembly reference assemblyname.dll

After trying numerous rebuilds and other fixes I came to this solution:

1. Remove the offending assemly reference from the reference list
2. Reinsert it
3. Build - fails
4. Revert
5. Buil - success!!!!

Not sure why but this works :)

Tuesday 6 January 2009

Exited with code -1073741819

I was having trouble building my VS2008 solution today due to the following error:

Error 1 The command "copy "C:\SVN\..." "C:\SVN\..." /Y
xcopy "C:\SVN\..." /S "C:\SVN\..." /Y" exited with code -1073741819.

This was occuring in my post build events on one of my project files.

My Solution:

IISRESET

Seems to do the trick :S