---
title: "How to use an HTML file in WPF"  
description: "How to use an HTML file in WPF"  
author: "Anonymous User"  
published: 2013-09-23  
updated: 2013-09-23  
canonical: https://www.mindstick.com/forum/1502/how-to-use-an-html-file-in-wpf  
category: "wpf"  
tags: ["HTML file in WPF", "wpf", "mindstick", "html file", "html5", "html5 tags"]  
reading_time: 1 minute  

---

# How to use an HTML file in WPF

I have a WPF [project](https://www.mindstick.com/articles/105927/how-to-excel-at-managing-multiple-projects) with a WebBrowser [control](https://www.mindstick.com/blog/197/asp-dot-net-repeater-control). I want to navigate to a HTML page that is in the project. When I build my project there is an HTML file called Rule1.html in my bin folder. I have tried the following:

System.Uri uri = new Uri("Rule1.html");

webb1.Navigate(uri);

I get the following error:

Cannot create [instance](https://www.mindstick.com/forum/155658/testing-connection-to-cloud-sql-instance-with-a-mysql-client-from-vm-instance) of 'MainWindow' defined in [assembly](https://www.mindstick.com/articles/25/global-assembly-cache) 'BB, [Version](https://www.mindstick.com/articles/12845/things-to-remember-while-migrating-odoo-to-a-better-version)=1.0.0.0, [Culture](https://www.mindstick.com/articles/44200/5-ways-to-improve-the-company-culture)=neutral, PublicKeyToken=null'. [Exception](https://www.mindstick.com/articles/1824/objective-c-exception-handling) has been thrown by the target of an invocation. Error in markup file 'MainWindow.xaml' Line 1 Position 9.

When I use an [absolute](https://www.mindstick.com/interview/1159/what-is-absolute-and-sliding-expiration-in-dot-net) Uri the [program](https://www.mindstick.com/blog/12337/scaling-up-your-mentorship-program) and control work fine, but I only want to use html pages that exist in my [application](https://www.mindstick.com/articles/12824/calculator-application-in-android) for the time being. How can I accomplish this ?

## Replies

### Reply by Pravesh Singh

Hi Alex,

I'm not sure if that URI creation statement even works, it doesn't seem to run on my machine.

You have to specify a path for it.

```
Uri uri = new Uri(AppDomain.CurrentDomain.BaseDirectory +
@"\Rule1.html");AppDomain.CurrentDomain.BaseDirectory "gets
the base directory that the assembly resolver uses to probe for
assemblies."
```


---

Original Source: https://www.mindstick.com/forum/1502/how-to-use-an-html-file-in-wpf

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
