wpfcefsharp

CefSharp Wpf WARNING:policy_logger.cc: Could not create policy manager as CBCM is not enabled


I am creating a WPF Console app using CefSharp and more specifically a ChromiumWebBrowser in my MainWindow's XAML. During the InitializeComponent() I am receiving the following message "[1106/121455.802:WARNING:policy_logger.cc(148)] :components\enterprise\browser\controller\chrome_browser_cloud_management_controller.cc(88) Could not create policy manager as CBCM is not enabled." which appears in the debbugging console each time my MainWindow window is activated. I know it is just a warning, but how can I remove it? I am not using any cloud services. Here is my MainWindow.xaml code for reference:

<Window x:Class="Manager.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:wpf="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf" 
    xmlns:local="clr-namespace:Manager"
    xmlns:uc="clr-namespace:Manager.WpfControls"
    xmlns:library="clr-namespace:Manager.library"
    mc:Ignorable="d"
    Title="Manager 6.1" Height="768" Width="1024"
    WindowState="Normal"
    WindowStyle="None">
<Border BorderBrush="#8090aa" BorderThickness="0" CornerRadius="2">
    <Grid>
        ...
        <wpf:ChromiumWebBrowser
             Grid.Row="1"
             x:Name="wb1"
             MinWidth="{Binding MinWidth}"
             Background="Transparent"
             Margin="0, 0, 0, 0"
             Padding="0, 0, 0, 50"
             JavascriptMessageReceived="wb_PostMessage"
         />
         ...
     </Grid>
</Border>

I am targeting .NET 7.0 and my CefSharp.Wpf.NETCore installer version is 117.2.40

I searched inside StackOverflow for all questions related to CBCM. As I understood it seems that the problems might be related to some extensions (which sould be enabled by default). So a recommendation was to add some settings in the code-behind (CefSettings) with a flag of "disable-extensions", but I am not sure how to implement this in my case, as it should be done in the XAML code in my case, in order to avoid its appearance from the initialization time. And overall, I am not sure this will solve my problem at all.


Solution

  • I did not solve the problem, but the comment of amaitland helped me hide the warnings in the log just by initializing the CefSharp before my MainWindow, thus on the App level.

    I put it here in case somebody find it useful for him as well.

    Here is the code I used:

        public partial class App : Application
        {
            public App()
            {
    #if ANYCPU
                //Only required for PlatformTarget of AnyCPU
                CefRuntime.SubscribeAnyCpuAssemblyResolver();
    #endif
                var settings = new CefSettings()
                {
                    LogSeverity = CefSharp.LogSeverity.Error
                };
                if (!CefSharp.Cef.IsInitialized)
                {
                    //Perform dependency check to make sure all relevant resources are in our output directory.
                    CefSharp.Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null);
                }
            }
        }