MicrosoftEdge / WebView2Feedback

Feedback and discussions about Microsoft Edge WebView2
https://aka.ms/webview2
434 stars 51 forks source link

"Value does not fall within the expected range" when caling NavigateToString #2281

Closed MojoDK closed 2 years ago

MojoDK commented 2 years ago

Description I have a mail exported from Outlook to HTML. I have no problem opening this HTML file in Edge nor in Visual Studio Code, but when I load it in WebView2, I get this error:

System.ArgumentException: Værdien falder ikke inden for det forventede område. (Value does not fall within the expected range)
   ved Microsoft.Web.WebView2.Core.Raw.ICoreWebView2.NavigateToString(String htmlContent)
   ved Microsoft.Web.WebView2.Core.CoreWebView2.NavigateToString(String htmlContent)
   ved Microsoft.Web.WebView2.WinForms.WebView2.NavigateToString(String htmlContent)
   ved Ic.Ui.Win.Controls.x.x.LoadHtml(String html) i D:\Develop\Assemblies\x\Controls\x\x.vb:linje 508

Eventhough my NavigateToString method is surrounded by Try/Catch, the application crashes.

Version SDK: 1.0.1150.38 Runtime: Stable Framework: DotnetFramework 4.8, VB.net OS: Windows 11 Pro x64 DK version 21H2

Repro Steps I have the HTML file that fails (and a sample project) - I can send it private to a Microsoft staff member, because of GDPR.

champnic commented 2 years ago

Hey @MojoDK - Thanks for the bug report, and sorry you are running into this. Is the html file larger than 2MB? Unfortunately there's currently a size limit when using NavigateToString. Are you able to navigate to the file using WebView2 in your app instead? You may also want to look into the SetVirtualHostNameToFolderMapping API: https://docs.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.core.corewebview2.setvirtualhostnametofoldermapping?view=webview2-dotnet-1.0.1150.38

If you want to send me the sample app, you can email me at champnic@microsoft.com. Thanks!

MojoDK commented 2 years ago

Hi @champnic - Thank you for your reply.

Yes the file is 25mb, så that is the reason. I will try to navigate instead.

Is it something that will be fixed in a later update?

champnic commented 2 years ago

The request to allow bigger files is in #1355. Thanks!