Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0x80004004 (E_ABORT)) Open file from Hard Disk #2297

Closed
Ali1Jamal opened this issue Jul 13, 2018 · 9 comments
Closed

0x80004004 (E_ABORT)) Open file from Hard Disk #2297

Ali1Jamal opened this issue Jul 13, 2018 · 9 comments

Comments

@Ali1Jamal
Copy link

@Ali1Jamal Ali1Jamal commented Jul 13, 2018

Hello:
I have a problem in windows forms opening a JS and HTML project from within the computer storage unit on my project. I have tried JS and HTML in Microsoft Edge and Firefox and it works normally but when I open the project in windows form using Microsoft.Toolkit.Win32.UI.Controls it gives me this error:

@kbrons

This comment has been minimized.

Copy link
Member

@kbrons kbrons commented Jul 13, 2018

Thanks for reporting the issue! Can you provide us with more information to replicate it? Such as the version of the toolkit you're using or a file that provokes the error?

Please try to follow the issue template next time as it helps us analyze the issue and provide a solution.

@rjmurillo can you take a look at this?

@Ali1Jamal

This comment has been minimized.

Copy link
Author

@Ali1Jamal Ali1Jamal commented Jul 16, 2018

yes
i download NuGet package from Microsoft v 3.0.0
my script in c#
`using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace webgl_3d_game_engine
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

    private void Form1_Load(object sender, EventArgs e)
    {
        webView1.Navigate(new Uri(@"file:///F:/Projects/js/IndigoCS-webgl-tutorials-master/Phong%20Lighting%20Intro/index.html"));
    }



}

}
`
the Exception:
System.Exception: 'Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT))'
and vs 2017 open WebViewControlHost.cs in line 477.
.
and Iam sorry for my English

@kbrons

This comment has been minimized.

Copy link
Member

@kbrons kbrons commented Jul 16, 2018

I just noticed this specific case is listed on the known issues of the webview control. Here is the workaround.

WebView controls don't recognize the File:// prefix. If you want to read a file into a WebView control, add code to your application that reads the content of the file. Then, serialize that content into a string, and call the NavigateToString(String) method of the WebView control.

Closing as it is a known issue.

@kbrons kbrons closed this Jul 16, 2018
@Ali1Jamal

This comment has been minimized.

Copy link
Author

@Ali1Jamal Ali1Jamal commented Jul 16, 2018

Thank you for explaining things to me.

@rjmurillo

This comment has been minimized.

Copy link
Contributor

@rjmurillo rjmurillo commented Jul 16, 2018

NavigateToString is great if you have content that has only external references or embedded resources. If you have relative resources or links, you can also try the NavigateToLocal method on the WebView. In 4.0 a new API exists that allows you to control how resources are loaded NavigateToLocalStreamUri. See #2195 and #2194

@Ali1Jamal

This comment has been minimized.

Copy link
Author

@Ali1Jamal Ali1Jamal commented Jul 19, 2018

@rjmurillo
Well, but I do not understand how to use this because I have not used Web View before. Can you give me a source of learning or steps to convert a file extension to a "Web View" because I've searched for a continuous day but I did not know how. and I would be thankful to you.

@rjmurillo

This comment has been minimized.

Copy link
Contributor

@rjmurillo rjmurillo commented Jul 19, 2018

@Ali1Jamal Here's a couple of examples. Given you have an application called MyWebView.exe in a folder C:\Apps\WebView, you could

  • Navigate to content relative to the application (C:\Apps\WebView\Content.html) by calling NavigateToLocal('/Content.html').
  • Navigate to content arbitrarily placed on the file system with NavigateToLocalStreamUri(Uri, IUriToStreamResolver) where the Uri is a relative URI (e.g. new Uri("/Content.html", UriKind.Relative)) and IUriToStreamResolver is an implementation of that interface, e.g. NavigateToLocalStreamUri(new Uri("/Content.html", UriKind.Relative), new CustomUriToStreamResolver()). The implementation will be called when any relative URI is resolved and is responsible for providing a System.IO.Stream of content to be consumed. Mostly this consists of translating the relative path to something that can be opened (e.g. System.IO.File.Open(...). See UriToLocalStreamResolver.cs as an example.
@Ali1Jamal

This comment has been minimized.

Copy link
Author

@Ali1Jamal Ali1Jamal commented Jul 19, 2018

@rjmurillo
work fine thank you. here is a webgl picture in this link.
https://imgur.com/HtqXIHB

@abhisheksonar1

This comment has been minimized.

Copy link

@abhisheksonar1 abhisheksonar1 commented Jun 1, 2019

@rjmurillo

can you please help me with NavigateToLocalStreamURri? I have the same issue with my code. I can navigate to the local html files using Navigate(new Url (@"C://")) in Windows 7, but in Windows 10 it returns an error similar to the one you mentioned.

I tried using NavigatetToLocalStreamUri but I have no prior experience in using a webview hence cant understand what should be the parameters. Can you help me out with an example?

@msftbot msftbot bot locked as resolved and limited conversation to collaborators Nov 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
5 participants
You can’t perform that action at this time.