0

I am developing a application in Xamarin for Mac. I have a html page whose build action is set to BundledResources and it is in root folder. My problem is that when I want to show it in WebView Control, It Does not open it. When I tries to open it using FileStream it throws UnAuthorizedAccessException. The exception does not comes in debug mode but when I build package through Xamarin and install it on a another machine where Xamarin Studio is not installed it throws the exception. the code is as below.

public void LoadHTMLPage()
{
    try
    {
        string filepath= NSBundle.MainBundle.PathForResource("HTMLPage", "html");
        NSUrl url = new NSUrl(filepath, false);
        string localHtmlUrl = filepath;
        if (File.Exists(localHtmlUrl))
        {
            MsgBox.Show("File Exist","");
            webBrowser.MainFrame.LoadRequest(new NSUrlRequest(url));
        }
    }
    catch (Exception ex)
    {

    }
}

Although MsgBox is displayed which shows that html file exists on the path.

Cœur
  • 37,241
  • 25
  • 195
  • 267

1 Answers1

0

Do you have sandboxing turned on (check entitlement file)? That would cause the behavior difference.

Chris Hamons
  • 1,510
  • 11
  • 22
  • thanx for response, the problem has been solved. it was because the html and other related files has not access. As I gave access the problem was fixed. – Vikas Mathur Oct 20 '16 at 12:10