Click here to Skip to main content
14,334,458 members
Rate this:
Please Sign up or sign in to vote.
See more:
I am trying to use date picker in my app but when i run the code in the emulator it shows the following error
"An exception of type 'System.Reflection.TargetInvocationException' occurred in and wasn't handled before a managed/native boundary
The program '[2184] TaskHost.exe' has exited with code -1 (0xffffffff)."

This is my code below
public partial class MainPage : PhoneApplicationPage
        Appointments appointments = new Appointments(); 
        // Constructor
        public MainPage()

            appointments.SearchCompleted += new EventHandler<appointmentssearcheventargs>(appointments_SearchCompleted);

            // Sample code to localize the ApplicationBar

        private void SearchCalendar()
            appointments.SearchAsync(DateBox.Value.Value, DateBox.Value.Value.AddDays(1), null);

        private void DateBox_ValueChanged(object sender, DateTimeValueChangedEventArgs e)

        void appointments_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
            if (e.Results.Count() == 0)
                MessageText.Text = "no events for the selected day";
                MessageText.Text = e.Results.Count() + " events found";
                DateList.ItemsSource = e.Results;

Kindly help
Updated 4-Feb-15 3:42am
Ramza360 4-Feb-15 9:47am
Where is the error occurring?
Member 10627743 4-Feb-15 9:55am
On this line "appointments.SearchAsync(DateBox.Value.Value, DateBox.Value.Value.AddDays(1), null);" of code
Richard Deeming 4-Feb-15 10:31am
A TargetInvocationException usually has an InnerException which contains the more interesting details.
Member 10627743 4-Feb-15 10:42am
I have solved it thank you all for your time
I ticked the required capabilities in the manifest

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100