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 will learn about sync provider notifications in Windows 11 and how to disable or enable it...
In this tutorial, let’s learn how to enable or disable the startup sound in Windows 11. By default, when Windows...
The CameraCaptureTask allows the Windows Phone 7 App to launch the Camera Application . This will be useful when the...