I’m digging deeper into WPF and learning more about XAML, web-XAML and XBAP. This evening i’ve stumbled across a nasty side-effect. When i’m creating an XBAP project in Visual Studio and run it without the debugger, the XBAP gets cached somewhere and any subsequent changes don’t show up – It keeps running the old XBAP file.
I’ve done a little digging and found out that the XBAP is cached by Click-Once when you run it outside the debugger. When executed, the application is deployed and run using Click-Once which (amongst other things) versions the assembly, checks for dependencies on the target machine and loads the application. If the application has been cached, then it will use the cached version instead. However you don’t have this problem when you’re running through the debugger because the process is launched by Visual Studio, and it will always run the latest assembly. This bugs me because I more frequently run my development apps outside the debugger and only attach when I need to. I know when my code is generally going to work, and most errors can be spotted without the need for attaching a debugger to the process.
Anyway the temporary solution is to add a pre-build event which clears the Click-Once cache and upon execution, the correct version of my app will be spawned. The command for the event is:
%windir%system32rundll32 %windir%system32dfshim.dll CleanOnlineAppCache
You can also run the command mage.exe -cc which is a CLI tool to do the same thing. More research is required into Click-Once and all this. Please note that this is a preliminary post, and I haven’t done much research in depth into the problem – if you know of a better way, i’d like to hear it!