Recursive workflows are not permitted

There was a change in Service Pack 2 of SharePoint 2007. Sadly, this change is both breaking and undocumented, which annoys me quite a bit, even though the change itself made sense.

Basically, SharePoint Designer Workflows cannot start themselves anymore. So if you have a Workflow that is started when an item is changed and you change the item from within the workflow, previously SharePoint would start a second instance of your workflow. This was both blessing and curse. Curse because if you were not careful, you would start an infinite loop. Not fun if your boss asks you why he received 4500 mails during the night… But blessing because you could use it to build State-Machine Workflows from SharePoint Designer.

I guess it’s the Infinite Loop part that triggered the change, and I think that change made sense. But please dear SharePoint team: Document a change like this, because it IS breaking, and you know as well as me that SP Designer Workflows cannot be debugged, so it’s not only a pain in the ass, but it’s also a way to really make people lose trust in your application.

Anyway, you can read more about this change at the SharePoint Designer Team Blog. The error message you will see in your SharePoint Logfile looks like this by the way:

08/26/2009 15:11:59.50 w3wp.exe (0x272C) 0x25E0 Windows SharePoint Services Workflow Infrastructure 72fv Unexpected AutoStart Workflow: Microsoft.SharePoint.SPException: Recursive workflows are not permitted. at Microsoft.SharePoint.Workflow.SPWorkflowAutostartEventReceiver.AutoStartWorkflow(SPItemEventProperties properties, Boolean bCreate, Boolean bChange, AssocType atyp)

Desktop Applications and the big ball of mud

I confess, I am normally a web developer, and one of my first lessons was to decouple user interface and business logic, that is: My ASPX Page is not actually doing much except passing data back and forth to some back end classes. It’s not necessarily MVC as the “View” may do some validation and some other stuff that belongs into the model or controller, but usually it’s clean.

A few weeks ago I started a WinForms application, which is my first foray into a real WinForms application (I have written some before, but those were very simple tools, not full-blown applications.) I have to admit that not much planning went into SWiki. I kinda knew what I wanted, but at the same time I didn’t because I had not used it yet. SWiki 0.8 was finished in about 6 hours and I started using it to create some real documentation. And by using it, I saw what did not work and what additional features are needed, which I put in a Road Map and implemented in the order I deemed appropriate. I’ve released 4 updated versions and I am about to release 0.13, and it just struck me.

The thing became a big ball of mud. Really, look at the code for the Main Form. I have the User Interface extremely tightly coupled to the database. In fact, if I want to programatically select another wiki page to display, I call the SelectPageInTree() function, which Selects a Page in the TreeView. This triggers the AfterSelect Event of the TreeView, which will change the Page. This is completely stupid. Even worse: I am currently trying to fix the Re-Parenting feature so that you can parent pages to the root page again. Unfortunately, there is no good way to do it without either making the UI illogical or having tons of side effects and more global variables.

Now, this does not mean that it’s beyond repair. SWiki is a rather small project and I can easily fix that with a day or two of work. But really, I have to go back to redesign and rebuild the UI from the ground up, now that I know which features I need. That’s not a complete rewrite, but I think Jeff Atwood is right when he said “Prepare to write your application three times”. SWiki 0.8 was already the second version (the first one was more a proof-of-concept/experiment, but still), so I guess that is my third time now πŸ™‚

As said, in a web application I found it rather natural to have Logic and UI separated, mainly because of the stateless nature and because I “rebuild” the UI on every request anyway. In a WinForms application, that is not the case, and I think it’s a lot easier to accidentially make your user interface part of the core application instead of just using it for Input/Output of data. I’m going to read about the MVP and MVVM patterns a bit I guess. MVVM is what is commonly used in MVC and WPF/Silverlight applications, so I do not know if it’s applicable to WinForms.

So yeah, still plenty of work to do until SWiki 1.0 (I am also thinking of renaming it because Swiki is already the name of another Wiki), but overall I am quite happy with how the current 0.13 alpha works, and at the end of the day, that’s what matters more than perfect code. I’m currently holding off the 0.13 release and merging it with the 0.14 version which had the UI Overhaul planned anyway.

Turning string.Format into an Extension Method

string.Format is the Bread and Butter function of every .Net developer, but somehow it feels a bit verbose. Here is a little extension method that allows you to do this:

string myTestString = "Hello {0}, Welcome to {1}, have a nice {2}!"; // Imagine this comes from a database or localized resource
string uname = "Dave";
string facility = "Initrode";
string timeOfDay = "afternoon";

// "old" way
lblWelcome.Text = string.Format(myTestString, uname, facility, timeOfDay);

// "new" way
lblWelcome.Text = myTestString.FormatString(uname, facility, timeOfDay);

// It gracefully handles nulls as long as it's a string, it will return string.Empty on a null string
string myNullString = null;
lblWelcome.Text = myNullString.FormatString(uname, facility, timeOfDay);

// Buzzword of 2009: Fluent Interface!
lblWelcome.Text = myTestString.Replace("Hello","Howdy").FormatString(uname,facility,timeOfDay).Trim().Reverse();

Not really life changing, but it’s one of those small things that just “feel” nicer/more fluent. Thanks to Kevin Dente for reminding me of string.Format again. I am using it every day and I always had it in the back of my head that I find it a bit “clunky”. So here is the extension method:

    public static class StringExtensionMethods
        public static string FormatString(this String input, params object[] args)
            if (input == null) return string.Empty;
            return string.Format(input, args);

Not Rocket Science, I know, but as said, even small things count if you just encounter them often enough πŸ™‚

Whatever happened to Advertising Games?

No no, I do not mean Advertising IN Games aka. “Why are the load times so long?” or “Daddy, why are the women on the advertised website nude?“. I mean Advertising Games, that is Games created by companies with the main purpose to promote their products (and no, I do NOT mean EA’s yearly sports games either!).

Back in the Amiga Games and in Germany, there were quite a few games that pretty much everybody who owned an Amiga had, games like Das Erbe and Das Schmutzige Erbe (created by the German Department of Nature*), Energie-Manager (by the Department of Economy*) or Das Telekommando (and Das Telekommando kehrt zurΓΌck) from Deutsche Telekom and two games from BiFi… (A list of Amiga Promo games is here)

Now I do not know if that is a German phenomenon (that Johnny Walker Game seemed to have some success outside of Germany as well), but those games were a relative success in terms of distribution. As they are free, they came bundled with magazines and shareware collections regularly. I just wonder: What happened to this genre? Sure, those games weren’t really “Game of the Year” material (Although the adventures were surprisingly good – the somewhat dark atmosphere in Victor Loomes or the first BiFi game is excellent) and had little to no replay value, but they gave a few hours of entertainment. The reason why I’m thinking about those games is that I just finished Dorito’s Dash of Destruction, a free ad game that is of mediocre quality, finished in about an hour, but it’s free and it’s a reasonably fun hour (and 200 free Gamerscore).

Do those games actually work out for the companies? Is it too expensive to develop them nowadays? Hard to believe, as said, ad games never took their appeal from the quality of their assets, they were simply appealing because they were free and did not suck too badly. Is it easier to reach people using Flash Games? Also hard to believe, but maybe I’m just the wrong audience. Heck, maybe it’s just because all the good Ad Games are adventures and the adventure genre went on hibernation a few years ago.

I don’t know. I don’t even know if there is even a point in this posting, except maybe to say “Bring back some good free adventure games!”…

* Isn’t in interesting how the German government saw computer games as a medium to reach people back in 1992, while in 2009 they seem to think that computer games are as evil as Hitler’s Mein Kampf?**
** And yes, Godwin’s Law on this post.

A simple .ini File parser for C#

Okay, so back in the old days, we had INI Files to store settings in. Those files are very simple:



Hardly exciting, but it gets the job done very well. Today I wanted to work with INI Files in my C# Application, both for reading and writing. But as I just found out, .net does not have built in functions for working with .ini files. It looks like they want everyone to work with XML Files now. Well, apart from the fact that XML looks like my keyboard puked on my hard drive and that the format is unneccesarily complicated for this purpose, I also found that reading and writing them is rather complicated, especially since the XmlSerializer has some stupid restrictions (one being that the class needs to be public – have they never heard of reflection?).

It’s great that the .net Framework is so powerful – I believe I can write a function that downloads an MP3 off the internet and uses it to generate a gradient in an image which then gets encrypted and sent per e-Mail in maybe 5 lines or so, but when it comes to something simple as saving some Key/Value Pairs, I still need a crapton of code. So I binged the internets a bit and found some code that uses P/Invoke to call Kernel functions to handle ini files, but I want to avoid P/Invoke at all costs. So in the end I simply wrote a class to Load/Save Ini Files.

It’s a simple class to interact with a simple file format that was created to store Key/Value pairs and that just works. Seriously, don’t change what isn’t broken. The class is licensed under WTFPL and can be downloaded here.

SWiki 0.12 released

Okay, a little change of plans. Originally, I wanted SWiki 0.12 to be localizable, but due to the fact that I’m not satisfied with the built-in features of Visual Studio I’m rolling my own framework now. This will however take a little longer.

Also, because SWiki is still under heavy development, I would have to chase translations first before I can release. So for the time being, I moved it to a later version in the road map.

Instead, I have added a feature to 0.12 that I really needed now that I’m actually using SWiki to create some documents, and that is re-parenting of pages. This allows you to move pages within the tree to other pages. You can not turn a page into a root page at the moment (that was an oversight, to be fixed in 0.13).

Additionally, the Page view now allows copying text through CTRL-C or Right Click => Copy, and in the navigation tree on the left, the Main Page will always be the first page. You can download SWiki 0.12 on the CodePlex Download Page.

Reinventing The Wheel, this time it’s a localization framework

If you look at the SWiki Roadmap, you will see that translated versions are planned for Version 0.12, which is incidentially the next version of SWiki. SWiki is intended to be just a bit outside of my reach, so that I can learn and grow from it. As I have no experience with creating a localized WinForms application, that allows me to learn how to do it πŸ™‚

Unfortunately, Localization support in Visual Studio 2008 left me somewhat unimpressed. So I set the “Localizable” property of my Form to true and then automagically it creates the resources I need and allows me to change any form settings, including Text, Position, Size etc. That is so far a great idea and works very well, but it has several drawbacks:

  • One resx file per form and language means exponential growth of files
  • The resx files are tied to the form – which means I cannot just put them in a “Localized” Folder
  • While it’s great that Forms are supported, I still have to find another way for my Exceptions and other Non-Form Code
  • Translations are stored in satellite assemblies. The Goal of SWiki is to have as few files as possible, preferably only one.
  • No way to share strings between different parts

In short: The built in support is unsuitable for SWiki. I have put my requirements in a StackOverflow question, but the answers were somewhat discouraging. I have looked around a bit and naturally also ended up at GNU Gettext which handles strings, but does not solve the problem of a) non-string content (Images, Location/Sizes of Controls) and b) the actual application of resources to the target.

One of the main issues is that the InitializeComponent() function is somewhat untouchable, as the designer will break if you change it too much and will replace your code with it’s own anyway. Visual Studio is certainly not lying when it tells you to not mess with the function.

So anyway, I have just decided to build my own localization framework for use with the SWiki UI. Finding a name was reasonably easy, I just called it “The Wheel”. I don’t know if it’s going to be much use, but just in case, it’s going to be licensed under Microsoft Reciprocal License (Ms-RL). Release Date? I don’t know, I hope by the end of the week.

SWiki 0.11 released

Another blog post – another SWiki update. That’s the good thing about starting with a small feature set, it allows for rapid expansion πŸ™‚ Along with many smaller fixes, there are two big points in this release.

Export Wiki into HTML Files
Using the now-functional export button in the button bar, you can export your wiki to HTML files. This will generate one file per page, complete with navigation.

Diff between Revisions
There is now a new “Diff” Tab on the main screen. This allows you to pick any two revisions of a page and quickly compare them.


Other changes
Apart from these two big points, there are some other changes. In the doc folder, you will find a more elaborate user manual in .swk format. The navigation menu on the left has a context menu now to add new pages. The Syntax Help window should no longer open outside of the screen if the SWiki window is too close to the edge.

Download SWiki for free on

SWiki 0.10 released

Development continues at a rapid pace, and SWiki 0.10 got a significant amount of changes. First of all, it accepts the filename of the database as a command line parameter. That means that you can have multiple wiki databases (for example, separate wikis for multiple projects you’re working on) but only need one SWiki.exe. Of course, it will still work if you do not specify a filename, in which case it uses “swikidb.swk” in the folder of SWiki.exe.

You can give a Title to each database now. To do that, simply click on the settings button (the cogwheel in the lower left button bar) and type in a title. The new Title will be reflected on the title bar as well, which is useful if you have multiple SWiki instances open.

There is a new Macro that you can use in your wiki pages to change the color of text: [color:ff0000|Your Text] will display the text in red. You can of course combine this with other format specifiers, for example *[color:0000ff|Your Text]* for bold blue text.

Also, there are a few UI Bug Fixes. The tab order should make sense in every window, and you can actually press return in the “New Page” dialog. Users of Version 0.9 will have to convert their database into the new format, as 0.10 changed the schema. To do that, there is an Upgrade tool included.

Download it for free from CodePlex now

SWiki 0.9 released

Okay, that was quick. I’ve just released 0.8 a few hours ago, but there was one feature I really wanted to have in a wiki that 0.8 does not have, and that is linking between articles in the wiki. As I am using the WebBrowser Control, I wasn’t sure if there is a way to interact with my C# Application from within the browser. As it turns out, you can easily interact through JavaScript! The WebBrowser supports the ObjectForScripting property, which allows to specify a (Com-Visible) Class to interact with. I just pass in “this” to make the Browser interact with my Main Form.

    this.browser.ObjectForScripting = this;

The next step was to create a function in my Form that can be called:

    public void BrowserInternalLink(int targetPageId)

I’ve created some code for testing that illustrates how to call it:

    sb.Append("<a href=\"javascript:window.external.BrowserInternalLink(1)\">Test</a>");

So this would call my BrowserInternalLink Function with the Parameter 1. Pretty neat, but still useless as it’s hardcoded πŸ™‚

The next step is to add support to the [wiki:PageId|Description] syntax to WikiPlex. Here, two articles are really important: Extending WikiPlex with Custom Macros and Extending WikiPlex with Custom Renderers.

If you want to add your own Tags to WikiPlex, you may need both usually. A Macro is some RegEx that tells WikiPlex to search for certain tokens and how to interpret them (For example, you can tell WikiPlex that you want to discard a part of the token, but pass other parts into a renderer). A renderer takes the Input and outputs some HTML. As said, your Macro is split into multiple parts (depending on your RegEx) and in theory you can pass every part into a different Renderer.

Have a look at WikiPlexExtensions.cs in the SWiki Source Code to see my implementation. The main downside of this whole approach is that it requires FullTrust, but so far I don’t know a better alternative. There is a GDI+ HtmlRenderer on CodeProject, but that sadly renders out images, which means: No links, no Copy/Paste, just look but don’t touch. The Mono Project seems to have a very interesting approach, but “Replacing the Browser” is currently low priority, especially since Windows 7 E will not happen πŸ™‚ (By the Way: SWiki is of course compatible with Windows 7)

I really like WikiPlex so far, as it is a very clean and extensible Wiki Parser, and I think I will have a lot of fun with it πŸ™‚

SWiki 0.9 also allows you to print out pages now, simply click the new Printer-Button on the lower left toolbar.

Grab it from CodePlex now πŸ™‚