0

I'm working on a Winforms project and want to display the About page content from an HTML file. I used the WebBrowser control for that but even though it works, I still get the following error message upon opening the solution or building the project:

Error Message

Is there any way to fix it or ignore it?

Here's the method call from the About page class:

    private void displayAboutContent()
    {
        this.labelVersion.Text = string.Format(@"Version: {0}",BoostEngine.r_CurrentVersion);
        UITools.displayHTMLPage(m_WebBrowser, m_ResourceName);
    }

and the UI Tools static class:

public static class UITools
{

    public static void displayHTMLPage(WebBrowser i_WebBrowser, string i_ResourceName)
    {
        Uri uri = new Uri(getFilepath(i_ResourceName));
        i_WebBrowser.ScriptErrorsSuppressed = true;
        i_WebBrowser.Navigate(uri);
    }

    private static string getFilepath(string i_ResourceName)
    {
        string projectPath = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
        string filePath = Path.Combine(projectPath, string.Format("Resources\\{0}.html", i_ResourceName));

        return filePath;
    }
}

P.S. I'm using this code on another form but receive the error only for the About page. Also important to note, I'm using a Parallels VM on Mac.

Thanks!

IR91
  • 3
  • 1
  • 2

1 Answers1

0

I don't know what is running code during solution load or compile, you might look in your project file for any targets that have been added.

But to simply get around the problem you could choose to not Navigate if the file doesn't exist:

if(System.IO.File.Exists("c:\\whatever"))
{
    i_WebBrowser.Navigate(uri);
}

If you do that you might consider loading a page that is guaranteed to be there or load a string of html to make it a little more user friendly with an appropriate message.

Crowcoder
  • 11,250
  • 3
  • 36
  • 45
  • I think that should do the trick, it's just weird because I couldn't trace the earlier call to the method and this path shouldn't be requested at any point. Thanks! – IR91 Dec 21 '19 at 14:51