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

This blog post will guide you through several effective methods to troubleshoot and resolve the issue of Microsoft Edge not...
Windows 11 offers a range of audio enhancements that can enrich your listening experience. These enhancements include features like virtual...
Windows 11 brings a fresh and visually stunning design to your desktop, and one of the standout features is the...