Today I encountered a problem with accessing the metadata for a WCF service that was deployed on a Windows Server 2003 machine.

The WSDL part worked just fine for the metadata exchange endpoint (url?wsdl, url?wsdl=wsdl0, etc.). These WSDL files refer to XSD files for the message types. Requesting these files (url?xsd=xsd0, url?xsd=xsd1, etc.) resulted in an empty response from the webserver. Checking the IIS logs indicated a HTTP 200 OK response with 0 bytes transferred. A very weird problem. Checking the config files did not lead anywhere.

Eventually I found a hint in a reply by James Zhang in this MSDN Forum post. The identity that is used for the application pool that hosts the WCF service must have the correct NTFS permissions on the %WINDIR%temp folder. The identity that I used is a domain account. After setting the right NTFS permissions, the problem disappeared.

The funny thing was that this particular answer wasn't the answer for the original question in this forum post.

James Zhang does not indicate what type of permissions are needed, so I had to experiment a little.

First I added the account to the local Users group. This gives it special access permissions: Traverse folder/execute file, create files/write data, create folders/append data  on this folder and subfolders. This is not enough. Then I realized, the domain account is already implicitly a member of this group because the Users group contains the NT AuthorityAuthenticated Users group. Next, I duplicated the extra rights that the NETWORK SERVICE account had for the domain account. These are list folder/read data and delete permissions for this folder, subfolders and files. This was enough. But it doesn't seem very secure. Now the service account can access temporary files created by other accounts.

So I experimented a bit more. I tuned back the NTFS permissions for the service account on %WINDIR%temp to list folder/read data on this folder only. This is just enough. This allows the account to see which files are in the temp folder, but it doesn't allow it to read the data in files that are owned by other accounts.

It is very unfortunate that WCF didn't give any clue about why it couldn't generate metadata in this case. It is also unfortunate that it needs just slightly more permissions that a standard user on the folder for temporary files.

Note that if you run your WCF service in an IIS application pool under the default NETWORK SERVICE account you won't run into this problem, because it has more than enough permissions.

PS: Best practices indicate you shouldn't deploy your services with metadata enabled. We will turn this off eventually. However, of course it should work if you do want to enable this.

I regularly sync my Windows Mobile phone with Outlook 2007 using ActiveSync/Vista Sync Center. I don't know what causes this, but every so often I end up with duplicate contacts and calendar items. This happens especially with recurring items like birthdays. If I am not quick enough to remove the duplicates, I end up with 2, 4 or even 8 of them!

In the past I have used the Duplicates Remover for Outlook from MAPILab for this. I used the trial edition that works for 30-days. It is limited to removing 10 items at a time, so I had to run it multiple times. I didn't use it often enough to shell out the $24/€19 to buy it.

Today I tried version 2.5.2 of this Outlook add-in. It has a wizard-like interface that is easy to use. I got my contact list and calendar cleaned up again.

[Full disclosure: By writing this review I am eligible for a free license for this Outlook add-in. This does not effect my opinion about this tool. Obviously, if I wouldn't find it useful, I wouldn't want to have a license.]

1 Comment

After a long day and night of coding, I released version of my Flickr Metadata Synchr tool on CodePlex this morning. I finally solved the long-standing problem I was having with the Windows Imaging Component (WIC) to update metadata. So this is the first fully-functional release of my application.

Functionality of FlickrMetadataSynchr v0.8.0.0

This is what the app does:

  • It allows you to select a set of your photos on Flickr and a folder on your hard drive with images.
  • It reads the metadata for both Flickr images and the local images. The metadata that is read is:
    • Title
    • Description
    • Author
    • Tags
    • Geo-info (GPS coordinates)
    • Date and time taken
    • Last update date and time
  • It matches images on Flickr with local images based on the date and time taken.
  • It determines on a per picture basis in what direction the metadata should by synced, i.e., which side should be updated, if any. Currently the most recently updated side wins. I am getting help from Timo Proescholdt for a better algorithm that will allow for a merge of metadata, i.e., a two-way synch.
  • It updates the metadata on Flickr and in the local images.

This is a screenshot of the app:


Previous posts on this tool

Workaround for WIC problems

During my holiday in France in July I received e-mail from Robert A. Wlodarczyk who works at Microsoft. He pinged me to say that he had released new sample code to update metadata using WIC. Yesterday, I tried to incorporate similar code into my application and ran into the same type of problems as before.

Because his sample was working, I wasn't ready to give up again. I finally tracked the problem down to a threading issue. WIC is throwing strange InvalidOperationException and InvalidFormatException exceptions with messages like "Cannot write to the stream" when it is called from a background thread. My app is multi-threaded so that the UI doesn't hang when it is busy syncing.

After I got confirmation from Robert that WIC indeed suffers from a threading issue, I solved the problem with a work around. I now marshal the call to the code that uses WIC to update metadata to the UI thread using the WPF Dispatcher object. This causes the app to become non-responsive for small amounts of time during the update of local metadata. But that is better than a non-fully-functional app.

Fully functional, give it a try

So all is well that ends well. After finally getting WIC to work, I could do away with the C++ code that was causing me headaches 😉 And my app now works on Windows XP again. You just need to have the .NET Framework 3.0 installed.

If you have images on Flickr and you have been busy tagging them, give my app a spin! You can always find the latest release on CodePlex. The source code is also available under a GPL license on CodePlex.

Installing is easy. You just need to unzip the ZIP-file, which contains three files, to a folder. Start the FlickrMetadataSynchr.exe file and you are done. The app remembers the last settings.

If you find any issues, please report them using the Issue Tracker for my app on CodePlex.

The Future

Even though the app is now able to sync metadata in both Flickr images and local images, there is always room for improvement. Here are my ideas, some of which are based of suggestions by people on CodePlex:

  • Improve the synchronization to also allow two-way synchronization for a picture pair. I.e., one side doesn't have to win. For example, if the Flickr image has just the title set and the local image the description, the metadata should be merged.
  • Add UI to see the match that is made by the tool and how it proposes to sync the metadata.
  • Allow you to exclude images if the match isn't good.
  • Allow you to overrule the sync proposal and sync the metadata in a different direction (on a per property basis) .
  • Add UI to store multiple mappings between Flickr sets and local folders. Currently the app only remembers the last folder and Flickr set that was used.
  • Add click-once deployment. That way the app can automatically check for new versions and update itself.

If you have any other ideas please post them at the discussions page for my app on CodePlex.

If you are interested in the history of LINQ to SQL and how it works internally, go watch Charlie Calvert's video with Matt Warren and Luca Bolognese.

The first 30 minutes of this video are primarily about the internals. The last 10 minutes focus on the history of LINQ to SQL and how it relates to its "predecessors" Cω  and ObjectSpaces. Matt and Luca also tell how Erik Meijer and Anders Hejlsberg got involved.

Related posts on this blog:

Back in January 2006 I wrote a blog post about a way to add input validation to declarative query string parameters in ASP.NET 2.0.

This involved adding code to the code-behind of each ASP.NET page to hook an event handler. This quickly becomes tedious if you have a lot of pages.

Will Shaver has come up with a better approach. He derives a custom class ValidatedQueryStringParameter from the ASP.NET class QueryStringParameter.

Check out the download on his blog post. It contains a more complete ValidatedQueryStringParameter class that supports other types besides Int32 like DateTime and Boolean. The QueryStringParameter already supports a Type property (of type TypeCode) to specify the type for the value of the parameter, so you can use it from markup like so:

<cc:ValidatedQueryStringParameter Name="CategoryId" QueryStringField="CategoryId" DefaultValue="0" Type="Int32" />

1 Comment

PDC07 has been postponed indefinitely. Dennis already warned me just before MIX07 that Microsoft wouldn't have anything to announce at the PDC after the MIX conference.

No new date for a PDC has been given, yet Microsoft already announced the date for MIX08! It will be held March 5-7, 2008 in Las Vegas.

So when will the next PDC be? The official statement by Microsoft is that it will be when they are ready to announce the "next wave of platform technologies".  The .NET technology is still forbidden from entering large parts of the Windows Operating System.

Will Microsoft attempt to pull off a synchronized wave of platform technologies  again? Synchronizing the release of

  • Visual Studio .NET 2005, .NET 2.0 and SQL Server 2005

  • .NET 3.0 and Windows Vista

proved to be mighty difficult for Microsoft to pull off. They only managed to release Windows Vista by cutting the dependencies between the OS and .NET. .NET 3.0 is only bundled with Windows Vista. Vista doesn't make use of it.

Vista even makes it very difficult to pull some things of using .NET. See my metadata API difficulty requiring me to use C++ and the fact that is is very difficult to create a decent Sidebar gadget using WPF.

The synchronization of .NET 3.5 and the ADO.NET Entity Framework failed. ADO.NET vNext has been delayed and will be released after the LINQ wave.

However, there is hope glimmering on the horizon. The new CoreCLR used by Silverlight 1.1 is able to co-exist with other CLR versions in one process. Silverlight will be a great technology for the Vista Sidebar. ASP.NET Ajax was released out-of-band. Microsoft has said that the next revision of the full CLR (remember .NET 3.5 still uses CLR 2.0) will also have this feature.

1 Comment

Martin Fowler notices a trend: interest in the .NET platform is declining. Ruby is all the rage. He has some recommendations for Microsoft on how to better collaborate with the community instead of going its own way. Martin noticed how Microsoft created its own unit testing variant that is incompatible with NUnit.

Change is visible in some parts of Microsoft, for example Microsoft is embracing dynamic languages, but boats the size of aircraft carries can only slowly change course. There are no clear signs from upper management at Microsoft that they are indeed changing course. The recent threats against the open source community over infringement on software patents seem to indicate that the old school closed-source thinking still has big strongholds within Microsoft.

Google is about to set a standard for offline storage for web applications with Google Gears. Even better, it's open source. Does Microsoft have the guts to embrace this technology instead of creating its own variant? I doubt it.

I am still pretty excited about the .NET platform. Especially about the LINQ wave of technologies coming with .NET Framework 3.5 and Silverlight. But I am also thinking about looking into Ruby on Rails more and more.

Not many Microsoft employees dare to publicly refer to WinFS as a black hole. Matt Warren does in this blog post. He gives us great insight into the origin of LINQ to SQL and how it managed to survive. He ends with:

So, for the sake of LINQ and the customer in general, we took up the OR/M torch officially, announcing our intention internally and starting the political nightmare that became my life for the next three years.

I briefly talked with Matt at PDC05. It was pretty clear already that he had had a big role in the development of LINQ to SQL even though the public presentation was done by Anders Hejlsberg. His blog is pretty quiet, but Matt is much more active on the MSDN Forums answering questions about LINQ to SQL.

1 Comment

I just experienced my first Windows Vista crash that didn't even display a Blue Screen Of Death (BSOD). My computer just suddenly rebooted, complaining about an improper system shutdown.

So what did I do?

I was trying to mount a VHD file (Virtual Hard Disk) with the vhdmount.exe tool from Virtual Server 2005 R2 SP1 RC. Apparently that made Windows Vista very unhappy.

So why did I want to mount a VHD file?

Windows Vista comes with the CompletePC Backup tool that allows you to backup an entire harddisk to a VHD file on an external hard drive. CompletePC Backup only allows you to restore the entire image in the case of hardware failure or system corruption. This makes it less then useful (as in completely useless) when you want to restore individual files. vhdmount.exe to the rescue! Or so you would think.

Is mounting a VHD file easy on Windows Vista?

No. This blog entry by the VirtualPC Guy would make you think that it is just a matter of installing the vhdmount.exe tool, importing some registry settings once, and just doubleclicking a VHD file. That doesn't actually work on Windows Vista with UAC turned on. The tool requires elevated priviliges and the Windows Explorer process doesn't have them. The tool doesn't initiate a UAC prompt to elevate. So you have to run a command line (cmd.exe) with administrative priviliges and run the vhdmount.exe tool from there.

Why did I want to restore some files?

I haven't actually lost data yet. I just wanted to make sure that I can restore my data in the unfortunate case that disaster chooses to strike in the future. The recent CodePlex disaster made me look into my own backup strategies again.

Now I know, that my backup strategy doesn't work ;(

Why didn't my backup strategy work?

My external USB-harddrive is formatted using the EXT2 filesystem (read here why) and I think the Ext2IFS driver doesn't play too well with vhdmount.exe. I'll have to investigate further, but the prospect of having to suffer through multiple crashes in the process is not very alluring.

1 Comment

Today, I wanted to continue working on my FlickrMetadataSynchr tool after a break of a month or so. This project uses SaaS in the form of a hosted Team Foundation Server by Microsoft for source control and work item tracking. This SaaS is called CodePlex

Team Foundation Server is known to be a very robust source control system that is based on SQL Server 2005. You can cluster the database tier, you can have hot standby for the application tier, etc.

Yet, Microsoft was able to corrupt the source control database and not have a proper backup schema in place. I.e., they thought they were making backups of the database, yet they weren't.

That will teach me not to trust a third party with my precious data. So based on my current experiences I don't trust Software as a Service (SaaS).

Even worse. Three weeks after the fact, Microsoft still cannot tell if the source control data will ever be restored. At some point you just have to admit you screwed up and say that nothing can be done about it anymore.

Luckily, I still have the latest version of my sources stored locally. But it is the nature of an integrated source control and work item tracking system that you can't keep a full local backup of the state of the system. If Microsoft (or another vendor) screws up you loose a lot of historic data.

Another SaaS that I have become to depend on quite heavily is Gmail. Considering the perpetual beta status of Google Mail, I have never fully trusted them to keep my data safe from disaster. I am very diligent in backing up my mail locally in Outlook PST files using the POP3 access that Gmail provides.

Do you trust SaaS?