Skip to content

Commit 9c2439f

Browse files
authored
Merge pull request #2396 from MicrosoftEdge/LoaderDllFolderPath-draft
API review for LoaderDllFolderPath.md
2 parents 37e9d70 + ed566b5 commit 9c2439f

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

specs/LoaderDllFolderPath.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Background
2+
The WebView2 loader code is what knows where to find and start or connect to already running WebView2 runtimes. This can either be statically linked for C based projects, or is also available as a standalone DLL. For .NET projects they must use the DLL since the loader code is native and we don't have a way to merge the native code into a managed module. Before this change the .NET WebView2 API module would look for the WebView2Loader.dll in the its same folder. But some .NET projects have requirements about where they can place DLLs and so this property is introduced to allow end developers to place the WebView2Loader.dll in any folder and specify the path of 'WebView2Loader.dll' explicitly.
3+
So we add an API to enable them to specify the path, so that they can use 'WebView2Loader.dll' from any path.
4+
5+
# Description
6+
We add new static `LoaderDllFolderPath` property in `CoreWebView2Environment` class.
7+
The property allow the end developers to specify the folder's path containing `WebView2Loader.dll`.
8+
9+
# Examples
10+
## C#
11+
```c#
12+
Task<CoreWebView2Environment> CreateEnvironmentAsync()
13+
{
14+
// Specify a relative path '.'. There should be a 'WebView2Loader.dll' file in the folder.
15+
CoreWebView2Environment.LoaderDllFolderPath = ".";
16+
return CoreWebView2Environment.CreateAsync();
17+
}
18+
```
19+
20+
# Remarks
21+
This property allows you to set the path of the folder containing the `WebView2Loader.dll`. This should be the path of a folder containing `WebView2Loader.dll` and not a path to the `WebView2Loader.dll` file itself.
22+
Note that the WebView2 SDK contains multiple `WebView2Loader.dll` files for different CPU architectures. When specifying folder path, you must specify one containing a `WebView2Loader.dll` module with a CPU architecture matching the current process CPU architecture.
23+
This property is used to load the `WebView2Loader.dll` module during calls to any of the static methods on `CoreWebView2Environment`. So, the path should be specified before any API called in `CoreWebView2Environment` class. Once `WebView2Loader.dll` is successfully loaded this property is no longer used.
24+
The path can be relative or absolute. Relative paths are relative to the path of the `Microsoft.Web.WebView2.Core.dll` module.
25+
If `LoaderDllFolderPath` is set and the `WebView2Loader.dll` file does not exist in that path or LoadLibrary cannot load the file, or LoadLibrary fails for any other reason, an exception corresponding to the LoadLibrary failure is thrown. For instance, if the file cannot be found a `DllNotFoundException` exception will be thrown.
26+
27+
# API Notes
28+
See [API Details](#api-details) section below for API reference.
29+
30+
# API Details
31+
## .NET and WinRT
32+
```c#
33+
namespace Microsoft.Web.WebView2.Core
34+
{
35+
public partial class CoreWebView2Environment
36+
{
37+
/// <summary>
38+
/// This property allows you to set the path of the folder containing the `WebView2Loader.dll`. This should be the path of a folder containing `WebView2Loader.dll` and not a path to the `WebView2Loader.dll` file itself.
39+
/// Note that the WebView2 SDK contains multiple `WebView2Loader.dll` files for different CPU architectures. When specifying folder path, you must specify one containing a `WebView2Loader.dll` module with a CPU architecture matching the current process CPU architecture.
40+
/// This property is used to load the `WebView2Loader.dll` module during calls to any of the static methods on `CoreWebView2Environment`. So, the path should be specified before any API called in `CoreWebView2Environment` class. Once `WebView2Loader.dll` is successfully loaded this property is no longer used.
41+
/// The path can be relative or absolute. Relative paths are relative to the path of the `Microsoft.Web.WebView2.Core.dll` module.
42+
/// If `LoaderDllFolderPath` is set and the `WebView2Loader.dll` file does not exist in that path or LoadLibrary cannot load the file, or LoadLibrary fails for any other reason, an exception corresponding to the LoadLibrary failure is thrown. For instance, if the file cannot be found a `DllNotFoundException` exception will be thrown.
43+
/// </summary>
44+
public static string LoaderDllFolderPath { get; set; }
45+
}
46+
}
47+
```

0 commit comments

Comments
 (0)