Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
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 Microsoft.Phone.ni.dll 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
C#
public partial class MainPage : PhoneApplicationPage
    {
        Appointments appointments = new Appointments(); 
        
        // Constructor
        public MainPage()
        {
            InitializeComponent();

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

            // Sample code to localize the ApplicationBar
            //BuildLocalizedApplicationBar();
        }

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

        private void DateBox_ValueChanged(object sender, DateTimeValueChangedEventArgs e)
        {
            SearchCalendar();
        }

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

Kindly help
Posted
Updated 4-Feb-15 3:42am
v2
Comments
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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900