Sunday, January 16, 2011

Silverlight Toolbox GestureListener not working great when developing using Remote Desktop


The Silverlight for Windows Phone Toolkit is working fine in normal environments, great toolkit. However when I started developing WP7 apps in the living room and used a Remote Desktop connection to the development machine I encountered very bad gesture responses in the Windows 7 Emulator. The Flick gesture on the emulator screen didn't do anything (well about 1 out of 100). Doing it again 1 minute later on de development machine without RDS and it worked all the time. Other gestures worked fine. Maybe it's something with the mouse events?

The XAML code I used:

<toolkit:GestureService.GestureListener>
<toolkit:GestureListener Flick="GestureListener_Flick">
</toolkit:GestureListener>
</toolkit:GestureService.GestureListener>

Code behind:

   1: if (ViewModel.ViewModelLocator.MainStatic.TossCmd.CanExecute(e))
   2: {
   3:     ViewModel.ViewModelLocator.MainStatic.TossCmd.Execute(e);
   4: }

Setting a breakpoint on line 1 never kicked in.

Friday, January 7, 2011

Property Bag issues

This time a minor blog post. It’s more for myself so I don’t forget.

This time it’s about the property bag in various object in SharePoint 2010. The problem I came across was how to remove a property bag key-value. But lets start at the beginning.

1- Add an value to the property bag.
 
//set value on (a new) Property bag 
if (web.Properties.ContainsKey("ExpireOn"))
{
web.Properties["ExpireOn"] = "some sting";
}
else
{
web.Properties.Add("ExpireOn","some string");
}
web.Properties.Update();

2- Remove an item from property bag

//Remove Property bag  
//Does not work
////web.Properties.Remove("ExpireOn");
////web.Properties.Update();

//Does work
web.Properties["ExpireOn"] = null;
web.Properties.Update();

As you can see, using Remove doesn’t work. You should set the value to null, call Update() on properties to persist the change to the database. At this point the null-ed Property bag key-value will be removed from the collection.

Sunday, October 17, 2010

Virtual Box Virtual Images won’t start after upgrading

After a few weeks of vacation and some other projects I started using Virtual Box again. As as usual I needed to update the application. I downloaded the new version (3.2.10), also noticed that it’s now all Oracle stuff. I started my a old virtual machine, however I always failed after a few seconds. Created a new virtual machine and again.

I tracked it down to the Storage section. Normally the VM configuration used the IDE controller. However in the new version I noticed that the virtual hard disk was mounted on the SATA controller.

So by default it looks like it attaches the VHD to the SATA Controller. I changed this back, so the VHD is now mounted on the IDE controller.

This fixed the problem, I can now start the VHD without problems. Probably an existing Windows 2008 VHD doesn’t like switching from IDE to SATA.

Monday, May 10, 2010

Running Hyper-V images with Sun VirtualBox

If you want to run your Hyper-V created or downloaded machines on Sun VirtualBox, you might experience some problems. When settings in VirtualBox are incorrect the image won’t start. I first thought it’s was about conflict with Hyper-V Integration Services or incompatibility between the Hyper-V vhd and VirtualBox. But luckily it’s just some configuration of VirtualBox to make it work.
So I have a SharePoint 2010 Hyper-V image and Next week I need to give a training and needed to use Sun VirtualBox as Hyper-V doesn’t run on Windows XP. So I copied the Hyper-V virtual hard disk to my local machine and followed the following steps.
  • Start VirtualBox
  • Create a new Virtual Machine
  • Do the basic settings
  • Add the Hyper-V virtual hard disk
  • Set IO APIC enabled in the Systems Tab (this is is important, otherwise it will hang after like 20 seconds on startup)

  • Start the VM in VirtualBox
  • Stopped the Hyper-V services and set startup type to: Manual

  • Installed the VBoxGuestAdditions for better integration with the virtual machine.
If you didn’t set the correct settings the virtual machine does start however after about 20 seconds (depending of your hardware) it hangs forever, and looks like this:

Thursday, April 15, 2010

Daily and Weekly SharePoint 2010 Site Collection backup using Powershell

Backup instructions for Site Collection, read TechNet http://technet.microsoft.com/en-us/library/ee748617(office.14).aspx
I want to backup the site collection daily and keep a backup of every week of the year. I created a Powershell script and scheduled the script.

The Powershell script does the following:

  • checks if SharePoint Powershell Snapin is loaded;
  • checks if backup location exists;
  • backups the site collection;
  • copies the daily backup to the weekly if necassary;

The ‘Backup Site Collection.ps1’ code:

"-------------------------------------"
"Yellow & Red SharePoint Backup script"
"-------------------------------------"
"- One daily backup"
"- And weekly backup"
#Backup location
$backupLocation = "\\XXX\d$\_backups\XXX\"
#Site collection location
$sitecollection = "http://XXX"
#daily filename
$dailybackupfile = Join-Path -Path $backupLocation -ChildPath "backup_yarintranet_daily.bak"
#weekly filename (using uformat as format doesn't have week option)
$weeklybackupfile = Join-Path -Path $backupLocation -ChildPath ("backup_yarintranet_" + (Get-Date -UFormat %Y%W) + ".bak")
# check to ensure Microsoft.SharePoint.PowerShell is loaded
$snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'}
if ($snapin -eq $null) {
    Write-Host "Loading SharePoint Powershell Snapin"
    Add-PSSnapin "Microsoft.SharePoint.Powershell"
}
if(!(test-path $backupLocation -PathType Container))
{
    "Backup location (" + $backupLocation + ") not found."
    break
}
"Starting backup process"
Backup-SPSite -Identity $sitecollection -Path $dailybackupfile -Force
"Finshed backup process"
"Copy daily backup to weekly if necessary"
if((test-path $weeklybackupfile -PathType Leaf))
{
    "Weekly backup file found, so no backup will be made"
    break
}
copy $dailybackupfile $weeklybackupfile -Force
"Finished"

 

Schedule the a task using the Windows 2008 scheduler.

image

Make sure that:

  • you set the correct Identity that has access to the backup location;
  • task runs even when user is not logged in;
  • Set interval of script execution in ‘Trigger’ tab;

image 

In ‘Action’ Tab set the execution of the Powershell script:

  • Program/script: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
  • Arguments: -file "<full path location to your Site Collection backup Powershell script>" (exclude the <, include the ")

And as always, make sure you test your backup. Otherwise you’ll have a very bad day when disaster strikes.