I can deploy my app successfully in Debug mode for both Nokia 710 and Emulator. However, when I change to Release mode in Visual Studio 2010 Ultimate, the NullReferenceException was thrown at this line
PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
in the file App.xaml.cs. The problem happens for both Nokia 710 and Emulator. One hypothesis is that VS has a bug causing System.Diagnostics.Debugger.IsAttached return true while there is no real Debugger “attacted”. Is there any suggestion to get around this problem?
Update: I try to comment everything in if (System.Diagnostics.Debugger.IsAttached). It doesn’t throw exception anymore. All I got when deploy it is the black screen and my app doesn’t run
I’m hesitating between whether I should delete this question or post the answer for it. Finally, I decided to keep it to help others won’t make any noob mistakes like this.
The answer for this question is very simple. When I set Release mode, I should do following steps:
That’s it.
I made a mistake when press F5 and think it will deploy. Actually F5 is for debug only; therefore, it throws exception when can’t find devices in debug mode.
Hope that help