Error when trying to use WebView2 in a Revit command

Error when trying to use WebView2 in a Revit command

ajimenezcu
Participant Participant
935 Views
2 Replies
Message 1 of 3

Error when trying to use WebView2 in a Revit command

ajimenezcu
Participant
Participant

Hi, I'm trying to use WebView2 in my own Revit command to open an HTML file that I have in a local directory. I'm new to Revit, and I don't understand why I'm getting an error when executing the following instruction:

private async void InitWebPage() { await this.webView21.EnsureCoreWebView2Async(null); string localPath = Path.Combine(Application.StartupPath, "..\..\HerramientaAuditoriaModelo\web\index.html"); }

The error occurs at the EnsureCoreWebView2Async(null) instruction and it is as follows: 'Unable to load DLL 'WebView2Loader.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)'

I have installed the latest version of Microsoft.Web.WebView2 (1.0.1823.32), and I'm using the Revit 2023 API. I have tried installing older versions that work for other users in their projects, such as version 1.0.818.41, but I still get the same error. I have also tested using WebView2 in individual projects that don't use the Revit API, and I can use WebView2 without any errors.

ajimenezcu_0-1686300371128.png

 

936 Views
2 Replies
Replies (2)
Message 2 of 3

Kennan.Chen
Advocate
Advocate

You need to ship some files with your app to use WebView2.

 

Distribute your app and the WebView2 Runtime - Microsoft Edge Development | Microsoft Learn

0 Likes
Message 3 of 3

NGM_AiYo
Advocate
Advocate
string location = Assembly.GetExecutingAssembly().Location;
DirectoryInfo directory = new DirectoryInfo(location);

var pathTmp = directory.Parent.FullName + "\\WebView2Loader.dll";
if (File.Exists(pathTmp))
{
Assembly.LoadFrom(pathTmp);
}

try load it by code, before program use the dll.
0 Likes