The name "WebView" does not exist in the namespace "clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf

7,958 views
Skip to first unread message

CB

unread,
Dec 7, 2012, 12:34:13 PM12/7/12
to cefs...@googlegroups.com
Hello,
Working in VS2012; trying to add a browser to a C# WPF application.  
I downloaded and extracted the CefSharp-0.12.7z package.  I have references to CefSharp and CefSharp.Wpf in my project.
In the xaml:
    xmlns:cs="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"
    <Grid>
        <GroupBox x:Name="groupBox" BorderBrush="Blue" BorderThickness="1" Margin="1,2,1,2">
            <!--
            <WebBrowser x:Name="Browser" Margin="3" />
            -->
        <cs:WebView x:Name="Browser"></cs:WebView>
        </GroupBox>
    </Grid>

Even though IntelliSense says "cs:WebView" is valid, I get the error mentioned when I try to build.
What am I doing wrong?
Thanks for any insights....

anthony taranto

unread,
Dec 7, 2012, 2:35:18 PM12/7/12
to cefs...@googlegroups.com
I'm not sure if if the xaml designer can reference controls from assemblies that mix managed and unmanaged code. Can you try adding the WebView to your Grid from code?

--Anthony


--
You received this message because you are subscribed to the Google Groups "CefSharp" group.
To view this discussion on the web visit https://groups.google.com/d/msg/cefsharp/-/4szrN76oOpgJ.
To post to this group, send email to cefs...@googlegroups.com.
To unsubscribe from this group, send email to cefsharp+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cefsharp?hl=en.

Clemens Hoffmann

unread,
Aug 9, 2013, 2:17:02 AM8/9/13
to cefs...@googlegroups.com, ccb...@gmail.com
Hello,
The problem is the VisualStudio Designer. This is running in a seperate process and need to load the DLLs for getting meta data. The designer fails to load the DLLS as the required CEF DLLd cannot be found.

I guess there are settings for the project/designer to tell the designer where the DLLs are located.

I used a "dirty" aproach as I was to lazy to saech for the settings. I added the path to the CEF DLLS to my user environment path. Then the desigger was able to load the DLLs and did not complain anymore.
greetings
    Clemens Hoffmann

Jim Nemtsov

unread,
Aug 9, 2013, 5:52:55 AM8/9/13
to cefs...@googlegroups.com, ccb...@gmail.com
Hi,
could you pls elaborate a little bit more ..
Just copied the example CefSharp.Wpf.Example from the latest build and referenced the dlls from CefSharp-master\Debug folder
bu I have the above error also
Thank you in advance

Clemens Hoffmann

unread,
Aug 9, 2013, 7:06:53 AM8/9/13
to cefs...@googlegroups.com, ccb...@gmail.com
Hello,
VisualStudio (devenv.exe) and the Visual Designer (XDesProc.exe) are seperate processes.
The visual designer somhow need to load the DLLs (in this case the CefSharp.Wpf.dll.
This DLL requires the CEF DLLS in order to be loaded. The visual designer does not know where the CEF libraries are located.
I added the path to the CEF libraries (the sub directory release) to my path in the user environment.
The sub folder debug does not contain the CEF libraries. They are in the sub directory release.
Then you need to compile the project and the designer should be able to show the window.
greetings
    Clemens hoffmann

Jim Nemtsov

unread,
Aug 9, 2013, 7:48:46 AM8/9/13
to cefs...@googlegroups.com, ccb...@gmail.com
Finally I did it thank You :)

Step by step for dummies (like me)
  1. Right-click 'My Computer' and select 'Properties'
  2. Click the 'Advanced' tab, then 'Environment Variables'. This opens
    the Environment Variables dialog.
  3. In the top 'User variables for ' pane, click on 'New' to create ADD 'PATH' variable,
  4. Add this to the beginning of the 'Variable value' field:
  5.   K:\MyFolder\CefSharp-master\Release;
    
  6. Click 'Ok' to close each open dialog



I even downloaded binaries and copy them to debug/bin folder.

Jim Nemtsov

unread,
Aug 9, 2013, 7:58:17 AM8/9/13
to cefs...@googlegroups.com, ccb...@gmail.com
Hmm, while the sample builds In Xaml I still have Invalid Markup?
And cannot preview window?

AdenFlorian

unread,
Aug 24, 2013, 7:36:24 PM8/24/13
to cefs...@googlegroups.com, ccb...@gmail.com
Jim,

I'm trying to figure out that same thing, but it seems CefSharp was not meant for people to be able to use the designer in visual studio.

If you need to do other things in the designer, you can just comment out the WebView line in the xaml, modify the design, then uncomment so you can run it again.

I probably don't know what I'm talking about.

shinn...@klnetwork.com

unread,
Aug 25, 2013, 7:13:30 AM8/25/13
to cefs...@googlegroups.com, ccb...@gmail.com
Thank you Jim,

To those who even dummier (like me :P) 

After did 5 steps what Jim suggested then you re-open Visual Studio, then select menu Build->Configuration Manager...-> Then make sure the DropDownlist 'Active solution configuration' was selected at 'Release' then you can compile whole project successfully.

Eric Shin

Per Lundberg

unread,
Aug 25, 2013, 4:07:42 PM8/25/13
to cefs...@googlegroups.com, ccb...@gmail.com
Aden,

I don't know if I would go as far as to say that it is "not mean for people to be able to us the designer in visual studio". :) I mean, it's not something that we have *deliberately* made impossible by any means. Then again, it is quite complex to support the VS designer for a mixed-mode (C++/CLR) assembly, which is dependent on other 3rd-party (i.e. libcef.dll etc) DLL files.

We would probably have to (for this to be a "click-n-play" kind of experience) build an .msi or .exe installer that installs CefSharp in C:\Program Files\CefSharp and adds that folder to the system PATH etc... If someone wants to do it, feel free. For me, this is totally a non-issue - I don't need to use the designer for the app in which I use CefSharp. In fact, the designer started working so bad for me (in another totally unrelated project) earlier this summer that I disabled it altogether...

Best regards,
Per 

Adam Łyskawa

unread,
Jun 12, 2016, 1:20:08 PM6/12/16
to CefSharp, ccb...@gmail.com
Hi.

I think I've found a workaround. I made a new UserControl:

public class MyBrowser : UserControl, IDisposable {
   
public ChromiumWebBrowser Chromium;
    public bool IsDesignMode => DesignerProperties.GetIsInDesignMode(new DependencyObject());
}

Then my UserControl initialization looks as follows:

public MyBrowser() {
   
if (!IsDesignMode) BrowserInitialization();
}

private void BrowserInitialization() {
   
Content = Chromium = new ChromiumWebBrowser();
}

It is very important all initialization code should be in separate method called if condition evaluates. When "Project Code" is enabled in Designer, it runs all constructors ignoring any conditions it finds, except when condition can be evaluated at compile time. So when I tried to put "if (IsDesignMode) return;" in constructor - it didn't work, the rest of the constructor code was executed anyway.
When "Project Code" is enabled, the conditional code is ignored and the ChromiumWebBrowser is not initialized. Designer works as charm. Problem solved.

All it takes now is to incorporate my solution into CefSharp.Wpf.ChromiumWebBrowser constructor to make such hacks redundant in future.

Please let me know if my workaround is useful, and if so, should I make a pull request on GitHub with the fix.

Best regards,
Adam Łyskawa
Reply all
Reply to author
Forward
Message has been deleted
0 new messages