You should change line 24 :
Code:
imvCompass.Initialize("")
to
Code:
imvCompass.Initialize("imvCompass")
It's necessary to declare an EventName to get the event routine working.
As no event was required in the original code, so no EventName was given.
Best regards.