Home | Blog | Publications | Photos | Services | About | Contact

Blog Archive - February, 2009

Back to Blog index.

Thu, 26 Feb 2009 17:21:59 GMT:
Code Contracts for .NET

Microsoft's DevLabs on MSDN has just recently released a new set of tools for .NET developers: Code Contracts. According to the documentation, Code Contracts "provide[s] a language-agnostic way to express coding assumptions in .NET programs. The contracts take the form of pre-conditions, post-conditions, and object invariants." Sounds good!

Code Contracts allows you to access a new namespace called System.Diagnostics.Contracts, and allows you to write Debug.Assert-like statements to check pre and post conditions in your code. However, the idea differs from Debug.Assert in that it is mostly for internal state/condition checks. On the other hand, Code Contracts allows you to use Visual Studio 2008 Team System to specify human or machine understandable conditions (more about this in the FAQ). To learn more, Code Contract's user manual is available here.

Note that this Code Contracts is a side-result of Microsoft research project called Spec#. Check it out as well.

Tue, 24 Feb 2009 15:40:01 GMT:
Hurry Up! Two days to download free Microsoft PDF books

I just recently learned that Microsoft has presently three PDF book offers available. But, you need to hurry up! These free offers are only valid up to 25th of February, i.e. tomorrow.

The books available for download are:

All these books require registration. Nonetheless, remember to act fast! :-)

Sat, 21 Feb 2009 14:24:58 GMT:
What's new in Windows Server 2008 R2?

Windows 7 is the hot topic today, but at the same time Microsoft is preparing Windows Server 2008 R2 (Release 2). Technically speaking, many new features will be part of this new OS release. Luckily, TechNet has an entire set of topics to teach you about Windows Server 2008 R2.

The document titled "Changes in Functionality from Windows Server 2008 to Windows Server 2008 R2" is available at Windows Server TechCenter.

Thu, 19 Feb 2009 19:10:14 GMT:
Internet Explorer 7 printing problem solved in Windows Vista

For some reason, one of my Windows Vista machines stopped printing any web pages in Internet Explorer 7 (IE7). The symptoms: when starting to print any web page (local or on the network), or previewing a page, and error message popped up saying:

[Window Title]
Windows Internet Explorer

Cannot find 'file:///C:/Temp/Low/HJIIIIU0.htm'. Make sure the path or Internet address is correct.


Well, I have changed the %TEMP% environment variable on that machine to point to C:\Temp. Under that directory I had a directory called Low, but no files existed there. On that part, the error message was correct. But why did creating files into this directory fail?

Turns out this was a security issue. From the information I found from the Internet, I gathered I needed to set the integrity level of the directory again, since it had changed for some reason that espaces me. The command you need to run is:

icacls C:\Temp\Low /setintegritylevel (OI)(CI)low

Running this command solved the problem.

Mon, 16 Feb 2009 20:23:08 GMT:
.NET 4.0 learning material: the training kit and the PDF poster

Today, while preparing for my ASP.NET session for the forthcoming technical sessions, I wanted to dig a bit deeper on the overall new features in .NET 4.0. Of course, there'a already quite a lot of information available for example on the .NET 4.0 Training Kit, but if you prefer, you can also download a nice overview PDF poster from the whole .NET 4.0 and the planned additions to the class library. This PDF was distributed at PDC, so if you attended the event, this might be old news. But in case you didn't, it might well not be.

The PDF poster is available here in print quality, but if you enjoy interactivity better, there's also a Silverlight-enabled DeepZoom version available.

Sun, 15 Feb 2009 21:01:47 GMT:
Installing Live Mesh preview on Windows Server 2008

I had heard of Microsoft's Live Mesh before, but when I saw J.H. from our ITpro.fi group to actually use it, I wanted to give it a try myself. I'm currently using the version 0.9.3424.14, and I must say I'm impressed. Works like a charm!

That is, on all computers I've tested it (four in total) except my Windows Server 2008 development machine. On Windows Server 2008, I could not install the utility, because I got an error message immediately after running LiveMesh.exe:

Live Mesh
This installation is forbidden by system policy.
Details about this problem can be found here.
[80070659] This installation is forbidden by
system policy. Contact your system administrator.

Now, ahem, which policy? I haven't set any explicit group policies on this server, so it couldn't be anything that like. Also, running the installation program with real admin rights ("Run as Administrator") didn't help either, "Product does not support running under an elevated [80080017]". No luck on the first try, that is.

Luckily, the help link on the original error message pointed me to an Windows Installer related property called DisableMSI. From the Windows Installer documentation on MSDN, I gathered that even though I haven't set an explicit policy, this is the same as I had disabled support for MSI installations.

Now, to solve the problem at hand, I needed to manually create an registry key to enable the installation of Live Mesh. Following the Windows Installer documentation, I created a key named "DisableMSI" (a 32-bit DWORD) under the registry key HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\Installer, and set its value to zero (0). After this, Live Mesh installed just great!

As a sidenote, Live Mesh starts transferring files from the monitored directory (directories) in about 30 to 60 seconds after they are placed to the folder. While the transfer operation is in place, the blue circle icon on the taskbar tray area spins, and you can see files with the .WLX appearing on the designated directory. These are "Live Mesh Placeholder Files". The application itself installs itself somewhat sneakingly under your profile, but this avoids running into UAC and security issues. On my machine, the installation path is C:\Users\Jani Järvinen\AppData\Local\Microsoft\Live Mesh\Bin\Servicing\0.9.3424.14.

Now, if you need to transfer (smallish) files from place A to B and/or you need to access your files from anywhere, try Live Mesh. Works well for me. Get started at www.mesh.com.

Keywords: How to install Live Mesh beta on Windows Server 2008.

Thu, 12 Feb 2009 15:44:32 GMT:
Fixing this RSS to be more compatible

Last week, I was kindly contacted by Microsoft, who asked whether they could include this blog feed into their own C# development feed. Of course, that sounds great to me, so in the future, you might also be able to read this blog directly from Microsoft's sites.

During the process, I learned that this RSS feed wasn't exactly valid as far as the latest RSS specifications are concerned. Luckily, W3 has a nice RSS validator service which I used to make sure no compatibility issues exist.

So now you reading this blog should be even more easier than it has in the past. Thanks for hanging on!

Wed, 11 Feb 2009 22:11:45 GMT:
New article in Tietokone about Photosynth

The second issue of the Finnish Tietokone magazine contains my latest article. This time, it's a two-pager about Microsoft Photosynth, the nifty little application to turn your digital photos into a walkable 3D model.

If you haven't already, go ahead and check Photosynth out!

Sat, 07 Feb 2009 19:07:38 GMT:
Updating many rows at a time in a DataTable

Need to do a fast bulk update to a .NET DataTable class from C#, but don't want to get bothered by connected data update events, etc.? Well, of course you could first eliminate all events from the DataTable, then update your data, and then restore the event handlers, but that seems like a lot of work.

Luckily, there's already a solution to this built into the DataTable class. This is a seldomly-known method called BeginLoadData, which according to the documentation, "turns off notifications, index maintenance, and constraints while loading data." That is, just what you are after!

Of course, there's also the corresponding EndLoadData method, which you must remeber to call once you are done with the update.

Fri, 06 Feb 2009 17:55:39 GMT:
Meeting with the Finnish ITpro.fi software development group

Yesterday, our Finnish ITpro.fi software development expert group had its winter meeting in Helsinki. This time, our topic were related to arranging future screencasts of .NET development related topics, with the first two screencasts already appearing on the site.

Nice meeting you again guys, and looking forward to the next meeting!

Mon, 02 Feb 2009 19:28:51 GMT:
Windows tip: Going quickly to special shell folders from the Start menu

Sometimes, you might want to go quickly to certain shell folders. In .NET development, you can use the System.Environment's GetFolderPath method to retrieve the location of these special folder locations, such as the desktop or the common application data folder. Also, you might recall how I've previously blogged about the location of the SendTo folder in Vista, and its somewhat difficult location in the file system. But, what if you wanted to quickly go to these shell folders interactively?

Luckily, there's an easy solution. Windows supports a special naming scheme with the "shell:" prefix in the Start/Search field or in the Start/Run dialog box. There are many such shortcuts, and for example by typing "shell:sendto" to Windows Vista's Start Search field, you can quickly open the SendTo folder at C:\Users\<user>\AppData\Roaming\Microsoft\Windows\SendTo. What a great timesaver!

I haven't found an official documentation page for this trick, but the following is a short list of several useful shortcuts. It seems that this tip works even with Windows 2000 (unable to verify while I'm writing this), but definitely from Windows XP, Windows Vista, and onwards.

shell:Administrative Tools
shell:Local AppData
shell:Start Menu
shell:Start Menu



› Blog Archive