CoreWebView2Environment Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
This represents the WebView2 Environment.
public class CoreWebView2Environment
type CoreWebView2Environment = class
Public Class CoreWebView2Environment
- Inheritance
-
CoreWebView2Environment
Remarks
WebViews created from an environment run on the Browser process specified with environment parameters and objects created from an environment should be used in the same environment. Using it in different environments are not guaranteed to be compatible and may fail.
Properties
BrowserVersionString |
Gets the browser version info of the current CoreWebView2Environment, including channel name if it is not the stable channel. |
FailureReportFolderPath |
Gets the failure report folder that all CoreWebView2s created from this environment are using. |
LoaderDllFolderPath |
The relative or absolute folder's path where WebView2Loader.dll exists. If LoaderDllFolderPath is set, we will load %LoaderDllFolderPath%\WebView2Loader.dll first. |
RenderAdapterLUID |
The graphics adapter LUID of the renderer. The host should use this LUID adapter when creating D3D device to use with CreateTextureStream(). |
UserDataFolder |
Gets the user data folder that all CoreWebView2s created from this environment are using. |
Methods
CompareBrowserVersions(String, String) |
Compares two instances of browser versions correctly and returns an integer that indicates whether the first instance is older, the same as, or newer than the second instance. |
CreateAsync(String, String, CoreWebView2EnvironmentOptions) |
Creates a WebView2 Environment using the installed or a custom WebView2 Runtime version. |
CreateContextMenuItem(String, Stream, CoreWebView2ContextMenuItemKind) |
Create a custom CoreWebView2ContextMenuItem object to insert into the WebView context menu. |
CreateCoreWebView2CompositionControllerAsync(IntPtr, CoreWebView2ControllerOptions) |
Create a new WebView in visual hosting mode with options. |
CreateCoreWebView2CompositionControllerAsync(IntPtr) |
Asynchronously creates a new WebView for use with visual hosting. |
CreateCoreWebView2CompositionControllerWithOptionsAsync(IntPtr, CoreWebView2ControllerOptions) |
Create a new webview in visual hosting mode with CoreWebView2ControllerOptions as parameter for multiple profiles support. |
CreateCoreWebView2ControllerAsync(IntPtr, CoreWebView2ControllerOptions) |
Create a new WebView with options. |
CreateCoreWebView2ControllerAsync(IntPtr) |
Asynchronously creates a new WebView. |
CreateCoreWebView2ControllerOptions() |
Creates a new CoreWebView2ControllerOptions object, which can be passed as a parameter in CreateCoreWebView2ControllerAsync(IntPtr, CoreWebView2ControllerOptions) and CreateCoreWebView2CompositionControllerAsync(IntPtr, CoreWebView2ControllerOptions) function for multiple profiles support. |
CreateCoreWebView2ControllerOptions(String, Int32) |
Create a new CoreWebView2ControllerOptions object, which can be passed as a parameter in CreateCoreWebView2ControllerAsync(IntPtr, CoreWebView2ControllerOptions) and CreateCoreWebView2CompositionControllerAsync(IntPtr, CoreWebView2ControllerOptions) function for multiple profiles support. |
CreateCoreWebView2ControllerWithOptionsAsync(IntPtr, CoreWebView2ControllerOptions) |
Create a new webview with CoreWebView2ControllerOptions as parameter for multiple profiles support. |
CreateCoreWebView2PointerInfo() |
Creates an empty CoreWebView2PointerInfo. |
CreatePrintSettings() |
Creates the CoreWebView2PrintSettings used by the PrintToPdfAsync(String, CoreWebView2PrintSettings) method. |
CreateSharedBuffer(UInt64) |
Create a shared memory based buffer with the specified size in bytes. |
CreateTextureStream(String, Object) |
Registers the stream id that the host can handle, providing a
texture stream when requested from the WebView2's JavaScript code.
The host can register multiple unique stream instances, each with
a unique stream ID, enabling the host to stream from different sources
concurrently.
The host should call this only once for unique streamId. The second
call of already created streamId without destroying
CoreWebView2TextureStream object will return an error.
|
CreateWebFileSystemDirectoryHandle(String, CoreWebView2FileSystemHandlePermission) |
Create a
|
CreateWebFileSystemFileHandle(String, CoreWebView2FileSystemHandlePermission) |
Create a
|
CreateWebResourceRequest(String, String, Stream, String) |
Creates a new CoreWebView2WebResourceRequest object. |
CreateWebResourceResponse(Stream, Int32, String, String) |
Creates a new CoreWebView2WebResourceResponse object. |
GetAutomationProviderForWindow(IntPtr) |
Returns the UI Automation Provider for the CoreWebView2CompositionController that corresponds with the given |
GetAvailableBrowserVersionString(String, CoreWebView2EnvironmentOptions) |
Gets the browser version info including channel name if it is not the stable channel or WebView2 Runtime. |
GetAvailableBrowserVersionString(String) |
Gets the browser version info including channel name if it is not the stable channel or WebView2 Runtime. |
GetProcessExtendedInfosAsync() |
Returns a snapshot collection of CoreWebView2ProcessInfo corresponding to all currently running processes associated with this CoreWebView2Environment excludes crashpad process. This provides the same list of CoreWebView2ProcessInfo as what's provided in GetProcessInfos(), but additionally provides a list of associated CoreWebView2FrameInfo which are actively running (showing or hiding UI elements) in the renderer process. See AssociatedFrameInfos for more information. |
GetProcessInfos() |
Returns the list of all CoreWebView2ProcessInfo using same user data folder except for crashpad process. |
GetProcessInfosWithDetailsAsync() |
Returns a snapshot collection of CoreWebView2ProcessInfo corresponding to all currently running processes associated with this CoreWebView2Environment excludes crashpad process. This provides the same list of CoreWebView2ProcessInfo as what's provided in GetProcessInfos(), but additionally provides a list of associated CoreWebView2FrameInfo which are actively running (showing or hiding UI elements) in the renderer process. See AssociatedFrameInfos for more information. |
GetProviderForHwnd(IntPtr) |
Returns the UI Automation Provider for the CoreWebView2CompositionController that corresponds with the given |
SetLoaderDllFolderPath(String) |
Set the path of the folder containing the |
UpdateRuntimeAsync() |
Try to update the installed Microsoft Edge WebView2 Runtime. |
Events
BrowserProcessExited |
BrowserProcessExited is raised when the collection of WebView2 Runtime processes for the browser process of this CoreWebView2Environment terminate due to browser process failure or normal shutdown (for example, when all associated WebViews are closed), after all resources have been released (including the user data folder). |
NewBrowserVersionAvailable |
NewBrowserVersionAvailable is raised when a newer version of the WebView2 Runtime is installed and available using WebView2. |
ProcessInfosChanged |
ProcessInfosChanged is raised when a collection of WebView2 Runtime processes changed due to new process being detected or when a existing process gone away. |
RenderAdapterLUIDChanged |
Listens for change of graphics adapter LUID of the browser. The host can get the updated LUID by RenderAdapterLUID. It is expected that the host updates texture's d3d Device with SetD3DDevice, removes existing textures and creates new texture. |
RestartRequested |
Add an event handler for the RestartRequested event. RestartRequested event is raised when there is a need to restart WebView2 process in order to apply certain beneifical updates. RestartRequested gives developers the awareness of these necessary WebView2 restarts, allowing developers to resolve issues faster than waiting for end users to restart the app. Developer might want to give end users the ability to save their state before restarting. For apps with multiple processes that host WebView2s that share the same user data folder you need to make sure all WebView2 instances are closed and the associated WebView2 Runtime browser process exits. See BrowserProcessExited for more details. |