Skip to content

Problem with global static attribute: Cef.IsInitialize #5035

Description

@PCX985485635

Is there an existing issue for this?

  • I have searched both open/closed issues, no issue already exists.

CefSharp Version

131.3.50

Operating System

Windows 10

Architecture

x64

.Net Version

.Net Framework 4.8

Implementation

WinForms

Reproduction Steps

Problem with global static attribute: Cef.IsInitialize:
When I was using the old version [109.1.110], I used multiple exe clients that worked, but after updating to the new version [131.1.50], I made some code changes:
Change 'if (! Cef. IsInitialize d)' to 'if (! Cef. IsInitialize d. HasValue | |! Cef. IsInitialize d. Value)'

When I open multiple exe clients, the error message is as follows:
Cef.Initialize can only be called once per process. This is a limitation of the underlying CEF/Chromium framework. You can change many (not all) settings at runtime through RequestContext.SetPreference. See https://github.com/cefsharp/CefSharp/wiki/General-Usage#request -context-browser-isolation Use Cef. IsInitialized to check if Cef.Initialize has already been called to avoid this exception. If you are seeing this unexpectedly then you are likely calling Cef.Initialize after you've created an instance of ChromiumWebBrowser, it must be called before the first instance is created.

From the error message above, it can be seen that the new version [131.1.50] seems to have Cef. every time a new client is executed IsInitialize will be null, causing the execution of the 'Cef. Initialize (settings, performanDependency Check: true, browserProcessHandler: null)' code after the 'if' code to be re executed

Expected behavior

When I want to open multiple clients (exe programs), only one initialization will be performed. Cef.IsInitialize will only execute the following code if the first client checks as fasle and all other clients are true:
Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null);

Actual behavior

When each client is first opened, CefIsInitialize is false, causing CefSharp to initialize multiple times

Regression?

No response

Known Workarounds

No response

Does this problem also occur in the CEF Sample Application

Yes using WPF/OffScreen command line args

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions