Category Archives: .NET

Using the TFS source control provider in CCNET v1.5 with 2010

Recently I helped a client of Falafel’s get up and running with Continuous Integration using CCNET v1.5. They’re running Team Foundation Server 2010 using TFS for their source repository and fortunately CruiseControl.NET includes a source control provider for TFS. Having tried this configuration and successfully we configured the server but ran into the following error:
Source control failure (GetModifications): Unable to find TF.exe and it was not defined in Executable Parameter
Reviewing the code for the TFS plugin we can see why this happens for 2010:

private string ReadTFFromRegistry()
    string registryValue = null;
    registryValue = registry.GetLocalMachineSubKeyValue(VS2008_64_REGISTRY_PATH, VS_REGISTRY_KEY);
    if (registryValue == null)
        registryValue = registry.GetLocalMachineSubKeyValue(VS2005_64_REGISTRY_PATH, VS_REGISTRY_KEY);
    if (registryValue == null)
        registryValue = registry.GetLocalMachineSubKeyValue(VS2008_32_REGISTRY_PATH, VS_REGISTRY_KEY);
    if (registryValue == null)
        registryValue = registry.GetLocalMachineSubKeyValue(VS2005_32_REGISTRY_PATH, VS_REGISTRY_KEY);
    if (registryValue == null)
        Log.Debug("Unable to find TF.exe and it was not defined in Executable Parameter");
        throw new Exception("Unable to find TF.exe and it was not defined in Executable Parameter");
    return Path.Combine(registryValue, TF_EXE);

As of this writing the CCNET documentation does not include the Executable parameter for this source control provider though the fix is easy enough.

FileSystemInfo.LastWriteTime and 12/31/1600

I’ve been working on an application tracking the age of files and if they reaches a certain threshold an error gets trigged.

FileInfo f = new FileInfo(new SystemPath(m.FolderName).Combine(m.FileName).ToString());
double totalminutes = DateTime.Now.Subtract(f.LastWriteTime).TotalMinutes;
if (totalminutes >= ErrorIntervalInMinutes)

I setup an error message to display information about the files when the error occurs and got something like this:

Error: File (d:\outbound\997_42772_06182010_1504_91.txt) File Time: 12/31/1600 4:00:00 PM Current Time: 6/18/2010 3:06:10 PM has failed to upload via FTP for 215356266.168919 minutes.

Whoa, over 400 years! That’s a lot of minutes not to mention 12/31/1600 looks a bit suspicious. A peek at the documentation for FileInfo.LastWriteTime reveals:

If the file described in the FileSystemInfo object does not exist, this property will return 12:00 midnight, January 1, 1601 A.D. (C.E.) Coordinated Universal Time (UTC), adjusted to local time. 

Ah ha! The list of files being processed in this case is static and files are getting uploaded to an FTP server so clearly the file causing the error is no longer on disk thus the error. Adding an if(!f.Exists) continue; should do the trick.

Now, I didn’t investigate UTC once converted to local time resulting in 12/31/1600 vs. 1/1/1601 but I found my answer and after adding a simple check I was on my way.

Updating my Starter Kit to Facebook Developer ToolKit v3.0 Take 1

Over the break I took a look at updating my Facebook Developer Toolkit (FDT) Starter kit to the latest v3.0 release that was announced at PDC. My first thought was to download the sources via SVN but unfortunately, that failed so I resorted to using the SDK Source download which I’d rather not do as it leaves no easy way to keep up-to-date with recent checkins.

Anyway, I built the sources which “just worked”, surely a good sign.

Next, I worked to compile and run my Starter Kit application and here is what I found (at least so far):

  • Delete old referenced assemblies
  • Change using statements:
    • using facebook; –> using Facebook
    • using facebook.web; –> using Facebook.Web;
    • using facebook.Schema; –> using Facebook.Schema;
  • Master.API.uid; –> Master.Api.Users.GetLoggedInUser();
  • Master.API.friends.getUserObjects(); –> Master.Api.Friends.GetUserObjects();
  •; -> Master.Api.Photos.GetAlbums();
  • facebook.Schema.user –> Facebook.Schema.user
  • Master.API.users.getInfo(Master.API.uid); –> Master.Api.Users.GetInfo(Master.Api.Users.GetLoggedInUser());
  • facebook.fql q = new facebook.fql(Master.API);
    • Add using Facebook.Rest
    • facebook.fql q = new facebook.fql(Master.API); –> Fql q = new Fql(Facebook.Session.FacebookSession);
  • Convert Site.Master page Page_Load method to a constructor setting RequireLogin = true;
  • Regular Expression bug

Until I get some time to resolve the RegEx issue the rest will be on hold for a bit though things are looking pretty good and the above didn’t take long at all. I have noticed a few worrisome comments on the discussion forum.

Thoughts on PDC 2009

image I’ve read a few articles that appeared on my Tweet stream regarding PDC this year and unfortunately they took a rather negative point-of-view. I’m always surprised when I read stuff like this:

Not since PDC 2003 has Microsoft talked so much and said so little. As I listened to the keynotes and have reviewed the sessions, words “series finale” repeatedly popped into my head — like a TV show coming to its end after a long run.
– Joe Wilcox
10 things about Microsoft’s PDC 2009: The good, the bad and the ugly

Unfortunately, to me that article reads very negatively and while I’m not quite sure what’s wrong in Joe Wilcox’s world to write such a piece I hope whatever it is it improves as things aren’t nearly as dreadful as he leads on.
I was in Orlando in 2000 when Microsoft announced the .NET framework which was clearly an inflection point though, rather somewhat messaged, they eventually delivered on Steve Ballmer’s Developers! Developers! Developers! message. I think we may reflect on this year’s PDC as an equally important inflection point as Microsoft delivers on a far more effective and cohesive cloud computing strategy than last years “services” effort. I didn’t attend PDC last year though I tried to grok their cloud strategy and left me wanting particularly when compared to what Amazon offered roughly a year ago which was Windows truly running in a cloud.
moves it does deliver on a number of fronts while at the same time it seems there were some obviously missing pieces though Microsoft stands on much firmer ground than they have in past years with Windows 7 being very solid with lots of new and interesting features and Internet Explorer 8 is a solid browser now that there’s lot’s of competition (Chrome, Safari, Firefox). Btw, I’ve more or less switched to using Chrome as my browser of choice from Firefox v3.5.
Some of the highlights I took away from this year’s PDC…
Windows Azure ContainerWindows Azure was the major announcement at this event and compared to last years nebulous and confusing messaging which I never understood this year was very clear. To drive home the message Microsoft parked a Azure container right in the convention hall for people to browse in an around. Now, of course, these kinds of containers are not new nor unique to Microsoft but I think it delivered a clear message that their cloude (that’s the spelling they used this year) is real and happening right now. They plan to start billing Feb 1 for their cloud services. In contrast to last year, MS will host user customized VM’s in the cloude similar to what Amazon has offered for awhile now albeit on the latest MS OS rather than Win2003.
Windows Azure ContainerWhile support for custom VM’s running in the cloud is cool, perhaps the most immediately useful part of the Azure story may well be SQL Azure with it’s support for TSQL using existing tooling which is particularly interesting as it offers a “near” immediate use for Microsoft’s cloud services. I think this offering may also put pressure on ISP’s hosting MSSQL to offer more competitive pricing because Microsoft’s offering looks very compelling:
Web Edition Relational Database for $9.99/month includes:

  • Up to 1 GB of T-SQL based relational database
  • Self-managed DB, auto high availability
  • Best suited for Web application, Departmental custom apps.

My blog is hosted at discountASP.NET which costs $10/month for half the disk space. That’s not to say there aren’t other distinguishing factors between the two offerings but clearly our choices have expanded.

Next was the Silverlight Beta 4 announcement which, in my mind, has clearly become Microsoft’s preferred UI platform trumping both WinForms (no surprise) and WPF. At ScottGu’s keynote he mentioned Microsoft has quickly pushed out three Silverlight releases in 22 months and that the quick pace was going to continue with his announcement of the availability of beta 4. The latest release nearly places Silverlight on the same level as WPF for developing native Windows applications just checkout the “Move beyond the browser” section on the above SL Beta 4 link. The other really important piece was ScottGu’s mention that many of the new features of SL 4 are in direct response to user feedback. That’s key and illustrates that Microsoft is listening and tuned into the developer community which is what’s going to drive the adoption of technologies like SL and more importantly, at least for Microsoft, Windows 7.
That gets to the laptop announcement where Microsoft enabled every attendee of PDC to start developing Windows 7 applications immediately. A great move IMO, one that further underscores Steve Ballmer’s developers message. If you don’t buy just look at the GUI builder Lino demonstrates here that Apple provides for iPhone development as used by Mono Touch. You can’t tell me that that’s a good tools story, it’s at least a decade behind Microsoft if not more.
Speaking of tools, PDC 2009 was all VS.NET 2010 and there are many exciting new features both in .NET 4 and on the tooling side for developing WPF and Silverlight applications and services. Rather than rehash a lot of what’s been covered I’d point you to this blog post which does a nice job of covering a lot of “what’s new”. In many ways I see Microsoft weaving a more integrated development experience as many of the technologies they’ve introduced over the several years are maturing and with 2010 we’re getting much more tightly integrated tooling and as a result a far better developer experience.
Be sure to checkout the new features in WCF 4 and check out Mark Miller’s coding guitar and for those of you Delphi guys, yes that’s the same Mark.

What’s Missing

The biggest hole was Mobile, a problem I believe might have been inadvertently highlighted during ScottGu’s keynote when he attempted to demonstrate what will be a very cool streaming feature on an iPhone that failed to work though they tried four different phones. In fact, the iPhone made an appearance in both Keynotes something I really never thought possible when on day one, Vivek Kundra, the US Chief Information Officer demo’ed an Azure based jobs application on the iPhone. I saw a lot of people with Apple devices like iPhones and Macbooks myself included but this was still very surprising.

The End

Falafel Software Booth PDC 2009 Wrapping up, I really enjoyed the week at PDC especially being there with John Waters and Lino Tadros from the Falafel team. We laughed a lot (BTW, not safe for work) and generally had a good time meeting lots of people at the Falafel booth.

PDC 2009 in LA

I’m in LA with Team Falafel (in booth 117, come on by!) for PDC09 where Microsoft has some announced some exciting developments in their cloud computing strategy otherwise known as $g(Windows Azure). The announcements this year go a long way towards really completing with $g(Amazon’s EC2) offering including support for user created VM images that can run in the cloud. The official rollout won’t occur until Feb 2009 when MS will actually begin billing for usage.

One of the other big announcements is the beta of $g(Silverlight 4). There are some really compelling features and it’s looking more and more like Silverlight will be the preferred UI not only on the web but on the desktop as well trumping both WinForms and WPF. One thing that was particularly interesting to me was a Facebook demo of a Silverlight 4 desktop application for a few reasons. One, the application was a real highlight of lots of the new features in SL4. Two, I’ve spent time working with the Facebook Developer Toolkit (FDT) which has a new 3.0 release with support for Silverlight and this time it seems to have a bit more support from Microsoft than in the past with a commitment to keep the API up-to-date.

All in all, the conference seems to be pretty well attended with perhaps the biggest news being the give-away of 1000’s of free netbooks to all attendees.

CruiseControl.NET VS.NET Starter Kit for plugin development

At the Silicon Valley Code Camp 2009 I gave a talk called Extending CruiseControl.NET through the use of plugins. I discussed the necessary steps and illustrated with an example ISourceControl provider using the LinqToTwitter OS project on Codeplex. The provider polls a configurable Twitter account looking for Tweets that that start with “CI:” allowing the Tweeter to trigger a build of the project simply be tweeting something like: “CI:Start the build”.

It’s a simple example but illustrates how easy it is to create CC.NET plugins an extend the platform to uses beyond classic Continuous Integration.

Here is a link to the Starter Kit. Btw, you will need to update the ThoughtWorks assembly references to match your build of CCNET.

Using Google Playground Examples in VS.NET

image I’ve been working on ways to leverage Google’s Calendar API to publish Falafel’s training calendar entries to the web. One of the things I stumbled into was the Google Code Playground which is a cool tool for testing out various Google API’s. The Playground includes Firebug lite which is also something I hadn’t run into, I love finding new cool things!
At any rate, this post is about how to get from the Playground to something live. In the screenshot to the right you can see the JavaScript source code in a code editor at the top right hand side of the screen. The missing piece here is that to get the code from the Playground to work on your own site you need to do a few things. First, you have to get an API Key. Once you’ve done that you can then add a <script> tag to include the Google GData API in your page.

    <script src="<your_key>" type="text/javascript"></script>

After, that you need to initialize the GData API and get the code from the Playground to execute. To do that I did two things.

  1. Wrapped the JavaScript code from the Playground page in a function.
  2. Added the following code to my page with a reference to call the JavaScript function
    <script type="text/javascript">
        google.load("gdata", "1");

”loadItems” above is the name of the function I created in Step 1. Next, I had to add a DIV tag to the page as a target for the new content:

<div id="content">

At this point, the page (plain HTML) can be debugged from VS.NET and/or uploaded to your domain and function correctly. Anyway, I learned a few things along the way and thought this might be useful.

dasBlog provider for use with BlogEngine.NET

I’ve used dasBlog since I first began hosting my own blog and previously considered a move to BlogEngine.NET (BE) but the URL’s aren’t compatible so there remains some investigation to figure out the best mechanism prior to switching. Unfortunately, dasblog seems to be on it’s final legs so spending time there at this point doesn’t seem wise.

To that end, I’ve been investigating various issues involved in a switch and in an attempt to make a transition easier I’ve created a BE provider which reads/writes blog posts and comments using dasBlog’s IBlogDataService rather than BE’s own XML provider. Basically, I’ve replace one XML provider with another, actually that’s not entirely true as this new provide is a descendant of XmlBlogProvider included with BE. Using this approach I avoid having to constantly re-import my blog data as I look into solving the URL issues.

I’ve made the code available via SVN on Google Code here so feel free to grab it and give it a go. I chose Google Code over Codeplex because the latter doesn’t want abandoned projects and I don’t see this as an ongoing project as it’s scope is quite narrow. What I’m interested in is any feedback regarding issues using the code and taking this sort of approach. In my initial playing around with BE it seems to function properly and allows me to use the “slug” feature of BE to “fix” at least part of the URL problem by simply removing spaces from Titles rather than replacing then with dashes.

Things I’ve tested (manually)

  • Adding/Editing/Deleting posts
  • Adding/Editing/Deleting comments

I haven’t played with images or attachments though my blog data seems to render fairly well. I can see some limitations such as no support for threaded comments though I don’t view this as a long term solution but I think it’s a step in the right direction.

Things that need testing/implementation:

  • DateTime conversions from dasBlog to BE
  • Image uploads
  • Windows Live support

Btw, I’m looking for help with the problem of retaining my existing URLs so if you’re a dasblog user and potentially interested in switching ping me and perhaps we can collaborate.

Text file processing with LINQ

After working on this problem the other day I started Googling looking for posts written about using LINQ for text file processing. I found the post Parsing textfiles with LINQ (or LINQ-to-TextReader) by Arjan Einbu.

LINQ shows us alternate ways to write code, introducing a more declarative coding paradigm. To use LINQ over the lines of a file, we can read all the lines in the file into a collection, and use LINQ over that collection. There’s some overhead to this; the need to read the entire file upfront and to fit the entire file in memory at once.

The solution was to create an extension method on TextReader for IEnumerable<string>. That post was followed up by another post, rather unfortunately titled, improving upon the solution using  TextFieldParser class in the Microsoft.VisualBasic.FileIO namespace, something I wasn’t aware existed and now find it odd this class is stuck well off in left field.

One of the reasons this subject interests me is I’ve been working with EDI files for awhile now and querying data directly from this file format would be really nice. For example, given a PO with line item segments like this:


You can calculate the total quantity, highlighted in yellow, of all line items using LINQ like this:

using (var reader = new StreamReader("c:\\edi\\inbound\\850_09022009_1311_89.txt"))
    var query = (from line in reader.GetSplittedLines("*")
                            where line[0].Equals("PO1") && line[2].Length > 0
                            select Convert.ToInt32(line[2])).Sum();
... }

Using Arjan’s implementation of GetSpittedLines, that’s his name not mine for the extension method he wrote, you can apply logic to any of the columns from the file which is pretty cool.

Of course, there are a myriad of ways of doing the same thing but it’s interesting to have access to the columns allowing for calculations and querying. For my EDI work I’m using FileHelpers which works well though I really like this LINQ option. That said, I haven’t done any benchmarking so I’m not sure about the performance but most of the PO’s I’m working with are less than 4KB and the volume isn’t so great that this would be a major factor. At any rate, I hope you find useful for you too.

Btw, if you’re looking for custom EDI implementations feel free to contact me.

ASP.NET Facebook Starter Kit for VS.NET 2008 updated to v0.8

I’ve updated my ASP.NET Facebook Starter Kit with the following improvements/changes:

  • Added support for dynamically resizable iframe which avoids a scrollbar though may have some side effects/caveats. Code is based on JavaScript sample from Facebook.
  • Added an example of XFBML which requires xd_receiver.htm (included) allowing for a Cross Domain Communication Channel
  • Added example of using FQL, refer to FQL.aspx
  • Updated Facebook Dev Toolkit assemblies
  • Added Facebook stylesheet from Bill Konrad

The download is here and full directions for installation and use are here. To see this application running on Facebook click here. As always, please direct questions on the Facebook API to the Developer’s Forum, or on the Facebook Developer’s Toolkit to the discussion list.

[Updated: Jan 15, 2010] This post is now outdated so please look for my updated versions. The latest is always available on my wiki.