Sep 18, 2007

Minor db4o tutorial problem

Some time ago I started playing with db4objects, an object oriented database for Java and .Net.

After installing db4o it started this tutorial (C:\Program Files (x86)\Db4objects\db4o-6.3\doc\tutorial\Db4objects.Db4o.Tutorial.exe, on my 64 bits Windows Vista Box) and everything went as smooth as possible but, when I tried to restarted it in the next day, it failed and the following dialog was shown:


Looking at this dialog we can see that the program failed to delete a file called formula1.yap under C:\Program Files (x86)\Db4objects\db4o-6.3\doc\tutorial\ folder; so I launched Process Monitor and pushed Reset button in tutorial program again.


It just confirms that the tutorial is failing to delete the file but why? Worse, why have it worked when we started it for the first time?

The .Net tutorial that comes with db4o has some minor bugs related to the way Windows Vista x64 handles writes to some specific paths, more specifically to %ProgramFiles% and %ProgramFiles(x86)% folders.

It's a Windows Vista feature called UAC (for detailed information about this topic please refer to this technet article) that prevents standard users (non administrators) from writing to some folders/registry keys, basically to keep the system more stable and secure. Actually it worked in the first time because

Ok, so how to fix this problem?

Basically there are 3 different approaches that can be applied:
  • The "Quick and Dirty" way (probably the easiest and fastest one) is to run the tutorial as an administrator. To do this just right click on the tutorial program and select "run as administrator".




  • The second one consists in adding a manifest next to the tutorial program ( (warning: Windows Vista/.Net will cache the tutorial program and will not pick you fresh manifest :(. In this case you can just "touch" the tutorial program -- or move it to another folder -- and Windows will load the manifest in the next time you start it as explained here). This simply instructs Windows to start the program with administrator rights.



  • The last one (and in my opinion the correct one) consists in fixing the tutorial in order to save this file under %LocalAppData% (or %AppData%) instead of its installation folder (thats the recommended action by Microsoft).



That's all folks ;)

In a future post I'll discuss a bit more about a UAC feature called File System and Registry Virtualization and why it wasn't applied in this case.

No comments: