The name ChromiumWebBrowser does not exist in the namespace “clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf”

后端 未结 5 797
难免孤独
难免孤独 2021-01-12 07:20

I had followed this link to implement CefSharp applicaton.

But I have stuck while coding MainWindow.xaml.

Blend for VS 2015 said,

相关标签:
5条回答
  • 2021-01-12 07:30

    You can read in the (Documentation) of the NuGet package, it's also necessary to add an app.manifest to your Application.

    0 讨论(0)
  • 2021-01-12 07:44

    For me the problem was that the solution platform was set to AnyCPU.
    As far as I know, CefSharp does not support AnyCPU. Interestingly the solution ran just fine in Release mode, but in Debug mode I immediately got an error - the invocation of the constructor on type that matches ... the specified binding constraints threw an exception.

    As soon as I changed the solution platform to be only x64, then the XAML error went away (The name ChromiumWebBrowser does not exist in the namespace “clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf”). And I could run the solution both in Debug and Release mode.

    0 讨论(0)
  • 2021-01-12 07:46

    its not supported in the XAML desginer, so load it in run time:

    1. Remove the element from the XAMl, and instead place any container such as a Border:

      <Border x:Name="cefChromeContainer" />
      
    2. in the Constructor code, after InitializeComponent(); call, craete the browser element and place into the container. even better to declare the browser in the class scoop:

      CefSharp.Wpf.ChromiumWebBrowser browser = new CefSharp.Wpf.ChromiumWebBrowser();
      
      public MainWindow()
      {
          InitializeComponent();
          cefChromeContainer.Content = browser;
          browser.Address = "https://stackoverflow.com";
      }
      
    0 讨论(0)
  • 2021-01-12 07:52

    I just tried the link, and as I mentioned in the comments it compiles without any problem.

    Can be ignored.

    And the preview is not available as well, I learned to live with it.

    No errors when compiling

    And the program starts up. No problem

    0 讨论(0)
  • 2021-01-12 07:52

    I had the same problem and i solve it changing configuration to from "debug" to "release" and using "x64" as platform.

    But it was not enought to change it from the solution menú, as i usually do. You need to go to visual studio main menú under "Compile > Configuration administration", as you can see in the following link from Microsoft:

    https://docs.microsoft.com/es-es/visualstudio/ide/how-to-configure-projects-to-target-platforms?view=vs-2015&redirectedfrom=MSDN#Anchor_0

    This solution was in fact in the Readme.txt file for cefsharp, as stated in the "Documentation" link provided by saschad in his answer: https://github.com/cefsharp/CefSharp/blob/cefsharp/69/NuGet/Readme.txt

    There you can read it:

    • For x86 or x64set your solution target architecture tox86orx64`, just changing the project is currently not enough (See https://msdn.microsoft.com/en-us/library/ms185328.aspx#Anchor_0 for details).

    Now I have it running like a charm :D

    0 讨论(0)
提交回复
热议问题