Skip to content

Commit 686135f

Browse files
author
Denghui Yu
committed
Update LoaderDllFolderPath.md
1 parent 9c2439f commit 686135f

File tree

1 file changed

+40
-19
lines changed

1 file changed

+40
-19
lines changed

specs/LoaderDllFolderPath.md

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,43 @@ The WebView2 loader code is what knows where to find and start or connect to alr
33
So we add an API to enable them to specify the path, so that they can use 'WebView2Loader.dll' from any path.
44

55
# 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`.
6+
We add new static `SetLoaderDllFolderPath` function in `CoreWebView2Environment` class.
7+
The function allow the end developers to specify the folder's path containing `WebView2Loader.dll`.
88

99
# Examples
1010
## C#
11-
```c#
11+
``` c#
12+
// Use default path
13+
Task<CoreWebView2Environment> CreateEnvironmentAsync()
14+
{
15+
// To use default path, just do not call SetLoaderDllFolderPath function or give a empty string:CoreWebView2Environment.SetLoaderDllFolderPath("") will use the default path;
16+
// The default search path logic is the same as loadlibrary
17+
return CoreWebView2Environment.CreateAsync();
18+
}
19+
20+
// Specify a absolute path
21+
Task<CoreWebView2Environment> CreateEnvironmentAsync()
22+
{
23+
// Specify a absolute path 'D:\\folder', and there should be a 'WebView2Loader.dll' file in the folder.
24+
CoreWebView2Environment.SetLoaderDllFolderPath("D:\\folder");
25+
return CoreWebView2Environment.CreateAsync();
26+
}
27+
28+
// Specify a relative path
1229
Task<CoreWebView2Environment> CreateEnvironmentAsync()
1330
{
14-
// Specify a relative path '.'. There should be a 'WebView2Loader.dll' file in the folder.
15-
CoreWebView2Environment.LoaderDllFolderPath = ".";
31+
// Specify a relative path 'sub/sub'. The absolute folder path is '%Microsoft.Web.WebView2.Core.dll%\sub\sub', and there should be a 'WebView2Loader.dll' file in the folder.
32+
CoreWebView2Environment.SetLoaderDllFolderPath("sub\\sub");
1633
return CoreWebView2Environment.CreateAsync();
1734
}
1835
```
1936

2037
# 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.
38+
This function 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.
2239
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.
40+
This function is used to load the `WebView2Loader.dll` module during calls to any other static methods on `CoreWebView2Environment`. So, the path should be specified before any other API is called in `CoreWebView2Environment` class. Once `WebView2Loader.dll` is successfully loaded this function will throw an InvalidOperationException exception.
2441
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.
42+
If 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 when any other API is called in `CoreWebView2Environment` class. For instance, if the file cannot be found a `DllNotFoundException` exception will be thrown.
2643

2744
# API Notes
2845
See [API Details](#api-details) section below for API reference.
@@ -32,16 +49,20 @@ See [API Details](#api-details) section below for API reference.
3249
```c#
3350
namespace Microsoft.Web.WebView2.Core
3451
{
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-
}
52+
/// <summary>
53+
/// Set the path of the folder containing the `WebView2Loader.dll`.
54+
/// </summary>
55+
/// <param name="folderPath">The path of the folder containing the `WebView2Loader.dll`.</param>
56+
/// <exception cref="InvalidOperationException">
57+
/// Thrown when `WebView2Loader.dll` has been successfully loaded.
58+
/// </exception>
59+
/// <remarks>
60+
/// This function 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.
61+
/// 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.
62+
/// This function is used to load the `WebView2Loader.dll` module during calls to any other static methods on `CoreWebView2Environment`. So, the path should be specified before any other API is called in `CoreWebView2Environment` class. Once `WebView2Loader.dll` is successfully loaded this function will throw an InvalidOperationException exception.
63+
/// The path can be relative or absolute. Relative paths are relative to the path of the `Microsoft.Web.WebView2.Core.dll` module.
64+
/// If 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 when any other API is called in `CoreWebView2Environment` class. For instance, if the file cannot be found a `DllNotFoundException` exception will be thrown.
65+
/// </remarks>
66+
public static void SetLoaderDllFolderPath(string folderPath);
4667
}
4768
```

0 commit comments

Comments
 (0)