UnauthorizedAccessException when using PhoneCallTask in Windows Phone

When using the PhoneCallTask (below code snippet) in Windows Phone 8 , i got an error “An unhandled exception of type ‘System.UnauthorizedAccessException’ occurred in System.Windows.ni.dll”.

UnauthorizedAccessException when using PhoneCallTask in Windows Phone 8
UnauthorizedAccessException when using PhoneCallTask in Windows Phone 8
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Tasks;

namespace PhoneApp3
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
            // SK To demonstrate PhoneCall Task Error
            PhoneCallTask task = new PhoneCallTask();
            task.PhoneNumber = "1111111111";
            task.Show();
        }
    }
}

You could avoid this error in Windows Phone Project by enabling (checking) the option ID_CAP_PHONEDIALER in the WMAppManifest.xml file of your Windows Phone Project .

UnauthorizedAccessException when using PhoneCallTask in Windows Phone 8
UnauthorizedAccessException when using PhoneCallTask in Windows Phone 8

Save the project with the above changes and build and run the project . You should see no exception after this 🙂

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

In this post, you’ll learn about the Win32 Error “0x000019E5 – ERROR_COULD_NOT_RESIZE_LOG” that you get when debugging system erors in...
In this post, you’ll learn about the error “CO_E_DBERROR 0x8004E02B” that is returned when working with COM based APIs or...
In this post, you’ll learn about the Win32 Error “0x000019D0 – ERROR_LOG_BLOCK_VERSION” that you get when debugging system erors in...