MsBuild Error MSB5009

In our rapid deployment strategy, we use msbuild.exe to build our .net solution files from the command line, which helps us build solutions without Visual Studio on our servers.  This has worked flawlessly for over a year now, but recently (after refactoring our solution file for efficiency) we got the infamous “Solution file error MSB5009: Error parsing the nested project section in solution file” message from msbuild.

Initially, I was stumped becasue the solution opened fine in Visual Studio – so I had no idea why VS2005 could build the solution, but msbuild could not.

After some Googling, I found this MSDN forum post, which outlined the same problem.  The solution, as outlined on the last post was supprisingly simple.

  1. In Visual Studio, add a new file to the solution (not the project), something like a text file.
  2. Save all.
  3. Remove the new file.
  4. Save all.

After I had done this, I commited the change, and tried again – and it worked great.  Obviously there was some old project references which was screwing up the works.  It now works fine and I am a happy panda once again.

APML 1.0 Initial Draft

Cross-posted from the Particls blog.

The APML community has been itching for the APML 1.0 Specification for a little while now, and Paul, our resident genius; has spec’d out the initial draft for community discussion.  You can find the intial draft, at http://groups.google.com/group/apml-public/web/apml-1-0-draft-1

From the Public Google Group:

This comes with a very large fore note: This is a very early draft only, and nothing is set in stone. Given that the community is obviously itching to start seeing APML 1.0 progress, I felt that it would be an appropriate time to release this and assist in structuring the discussion. I intend to follow this with a few more emails that detail individual sections I believe need substantial addressing.

APML version 1.0 proposes a number of substantial changes over the previous 0.6 version, with some of the changes including, but not limited to;

  • The Addition of an ‘Entity’ node to describe (People, Businesses and other non-metaphysical interests.
  • The Addition of a ‘Location’ node to outline places of interest.
  • The inclusion of an rdf:about node attribute to allow for richer RDF-type ontologies without reducing the “simple” nature of APML.

APML has come a long way since its inital conception a little over 2 years ago.  And I am very proud to be involved with a community of people all dedicated to creating an open format to give attention back to the people who own it.

The APML Workgroup is committed to ratifying this standard as soon as public commenting is evalutated, and is tasked to provide a smooth transition to the new version; so please feel free to head over to the public Google Group and put in your 2c.

Design Patterns: Elements of Reusable Object-Oriented Software (Hardcover)

Amazon.com
Design Patterns is a modern classic in the literature of object-oriented development, offering timeless and elegant solutions to common problems in software design. It describes patterns for managing object creation, composing objects into larger structures, and coordinating control flow between objects. The book provides numerous examples where using composition rather than inheritance can improve the reusability and flexibility of code. Note, though, that it’s not a tutorial but a catalog that you can use to find an object-oriented design pattern that’s appropriate for the needs of your particular application–a selection for virtuoso programmers who appreciate (or require) consistent, well-engineered object-oriented designs.

This book is the bible.  If you’re a developer and dont have this book buy it now!  Ina  startup world, where abstraction, scale and writing re-usable code is paramount.  This book will give you the tools you need to do it.

Fantastic .Net Design Pattern Examples

Design patterns are recurring solutions to software design problems you find again and again in real-world application development. Patterns are about design and interaction of objects, as well as providing a communication platform concerning elegant, reusable solutions to commonly encountered programming challenges.

The Gang of Four (GoF) patterns are generally considered the foundation for all other patterns, and the website contains an awesome set of .Net examples for each of the patterns.

Extending Explorer with Band Objects using .NET and Windows Forms

One of the great things about Firefox, is how easy it is to extend. Internet Explorer and Windows Explorer, not so much.  If you’re a ATL or COM guru then you might not find it so hard, but for those of us from a Managed Code background; its like splitting wood in your eyes.

A while ago I found a great article on CodeProject by Pavel Zolnikov, which walks you through the implementation of an Explorer bar with the help of BandObject base class. Describes implementation details of the BandObject class.

This was excellent, but it really didn’t work using the .Net 2.0 framework – that is until I found this little gem Band Objects – .NET 2.0 Redux.

Flot

Recently, I’ve been looking for a graphing library, that…well…didn’t suck. I was even prepared to part with my cold-hard cash to get the library. While discussing this with a friend he pointed me to Flot and I’m reasonably confident that “wow” cam out of my lips. This description came from the Flot, Google Code page:

Flot is a pure Javascript plotting library for jQuery. It produces graphical plots of arbitrary datasets on-the-fly client-side.

The focus is on simple usage (all settings are optional), attractive looks and interactive features like zooming.

Although Flot is easy to use, it is also advanced enough to be suitable for Web 2.0 data mining/business intelligence purposes which is its original application.

The plugin is targeting all newer browsers. If you find a problem, please report it. Drawing is done with the tag introduced by Safari and now available on all major browsers, except Internet Explorer where the excanvas Javascript emulation helper is used.

It can do all kinds of sexy graphs…

…and full AJAX graphs.

I am very impressed with this graphing library and think it will be my library of choice.

Using ASP.NET 2.0 along with Microsoft Speech API.

I’ve done a lot of feed reading and writing over my more recent professional career, and something that has always been a fascination of mine, has always been an engine which could “read” RSS/ATOM feeds.  That is, an engine which can turn a feed, into a set of MP3’s.

I had bookmarked this page a while ago, and found it when cleaning up my bookmarks.  I didn’t want it bookmarked anymore so I thought I would blog it and share the link with the other 2 people subscribed to this blog.

The library itself is not too shabby, but the Microsoft Speech Engine is actually pretty lame.  I guess there is always time though.

The code looks like:

private void SoundFeed(string url, int itemCount)
{
try
{
RssFeed feed = RssFeed.Read(url);
RssChannel channel = (RssChannel)feed.Channels[0];

if (channel.Items.Count > 0)
{
SpVoice readr = new SpVoice();
readr.Speak(“Your are listening to “ +
channel.Title + “.”,
SpeechVoiceSpeakFlags.SVSFDefault);

int counter = 1; // num of items tracker
foreach (RssItem item in channel.Items)
{
if (counter > itemCount)
break;
if (!item.Title.Trim().Equals(string.Empty))
{
readr.Speak(“Reading Item “ +
counter.ToString() + “.”,
SpeechVoiceSpeakFlags.SVSFDefault);
readr.Speak(“Title of the Post: “,
SpeechVoiceSpeakFlags.SVSFDefault);
readr.Speak(item.Title.Trim(),
SpeechVoiceSpeakFlags.SVSFDefault);
readr.Pause();
}

if (!item.Description.Trim().Equals(string.Empty))
{
readr.Resume();
readr.Speak(item.Description.Trim(),
SpeechVoiceSpeakFlags.SVSFDefault);
}

counter++;
}
}

}
catch (Exception ex)
{
throw (ex);
}
}

I think I shall have to play with this some more soon and make me a Windows Mobile 6.0 app to download podcasts for me to listen to each night.

Mobile Browser User-Agent Detector

While working on a project recently I needed to be able to determine if the user was coming to the ASP.Net site was using a mobile browser. In my particular case, the IsMobileBrowser property didn’t work so I created this code to do it for me, based on the information i gleamed from http://www.zytrax.com/tech/web/mobile_ids.html. Enjoy.

string[] arr = new string[]
{
"Windows CE",
"PlayStation Portable",
"PLAYSTATION 3",
"Symbian OS",
"SonyEricsson",
"Opera Mini",
"SIE",
"Vodafone",
"SEC",
"SAMSUNG",
"SCH",
"240x320",
"MobileExplorer",
"PalmSource",
"PalmOS",
"Smartphone",
"BlackBerry",
"iPhone"
};

foreach (string s in arr) {
if (Context.Request.UserAgent.ToLower().Contains(s.ToLower()))
Response.Redirect("/mobile.aspx");
}

PatternLayout Modifiers in Log4net

Log4net is an awesome library. For anyone who develops in .Net and doesn’t use it, I highly suggest you do. Code Project has a great article on how to use log4net for those who have not used it before.

But while I love the library as an awesome way to manage escalating logs within an application, it frustrated me trying to find a list of the default PatternLayout Modifiers. After some Googling I found it!

Conversion Character Effect
a Used to output the frienly name of the AppDomain where the logging event was generated.
c

Used to output the logger of the logging event. The logger conversion specifier can be optionally followed by precision specifier, that is a decimal constant in brackets.

If a precision specifier is given, then only the corresponding number of right most components of the logger name will be printed. By default the logger name is printed in full.

For example, for the logger name “a.b.c” the pattern %c{2} will output “b.c”.

C

Used to output the fully qualified class name of the caller issuing the logging request. This conversion specifier can be optionally followed by precision specifier, that is a decimal constant in brackets.

If a precision specifier is given, then only the corresponding number of right most components of the class name will be printed. By default the class name is output in fully qualified form.

For example, for the class name “log4net.Layout.PatternLayout”, the pattern %C{1} will output “PatternLayout”.

WARNING Generating the caller class information is slow. Thus, it’s use should be avoided unless execution speed is not an issue.

d

Used to output the date of the logging event. The date conversion specifier may be followed by a date format specifier enclosed between braces. For example, %d{HH:mm:ss,fff} or %d{dd MMM yyyy HH:mm:ss,fff}. If no date format specifier is given then ISO8601 format is assumed (ISO8601DateFormatter).

The date format specifier admits the same syntax as the time pattern string of the ToString.

For better results it is recommended to use the log4net date formatters. These can be specified using one of the strings “ABSOLUTE”, “DATE” and “ISO8601” for specifying AbsoluteTimeDateFormatter, and respectively ISO8601DateFormatter. For example, %d{ISO8601} or %d{ABSOLUTE}.

These dedicated date formatters perform significantly better than ToString.

F

Used to output the file name where the logging request was issued.

WARNING Generating caller location information is extremely slow. It’s use should be avoided unless execution speed is not an issue.

l

Used to output location information of the caller which generated the logging event.

The location information depends on the CLI implementation but usually consists of the fully qualified name of the calling method followed by the callers source the file name and line number between parentheses.

The location information can be very useful. However, it’s generation is extremely slow. It’s use should be avoided unless execution speed is not an issue.

L

Used to output the line number from where the logging request was issued.

WARNING Generating caller location information is extremely slow. It’s use should be avoided unless execution speed is not an issue.

m

Used to output the application supplied message associated with the logging event.

M

Used to output the method name where the logging request was issued.

WARNING Generating caller location information is extremely slow. It’s use should be avoided unless execution speed is not an issue.

n

Outputs the platform dependent line separator character or characters.

This conversion character offers practically the same performance as using non-portable line separator strings such as “\n”, or “\r\n”. Thus, it is the preferred way of specifying a line separator.

p

Used to output the level of the logging event.

P

Used to output the an event specific property. The key to lookup must be specified within braces and directly following the pattern specifier, e.g. %X{user} would include the value from the property that is keyed by the string ‘user’. Each property value that is to be included in the log must be specified separately. Properties are added to events by loggers or appenders. By default no properties are defined.

r

Used to output the number of milliseconds elapsed since the start of the application until the creation of the logging event.

t

Used to output the name of the thread that generated the logging event. Uses the thread number if no name is available.

u

Used to output the user name for the currently active user (Principal.Identity.Name).

WARNING Generating caller information is extremely slow. It’s use should be avoided unless execution speed is not an issue.

W

Used to output the WindowsIdentity for the currently active user.

WARNING Generating caller WindowsIdentity information is extremely slow. It’s use should be avoided unless execution speed is not an issue.

x

Used to output the NDC (nested diagnostic context) associated with the thread that generated the logging event.

X

Used to output the MDC (mapped diagnostic context) associated with the thread that generated the logging event. The key to lookup must be specified within b

races and directly following the pattern specifier, e.g. %X{user} would include the value from the MDC that is keyed by the string ‘user’. Each MDC value that is to be included in the log must be specified separately.

%

The sequence %% outputs a single percent sign.