How to embed cefsharp to winforms

6,776 views
Skip to first unread message

Ribhararnus Pracutian

unread,
Sep 14, 2013, 6:37:44 AM9/14/13
to cefs...@googlegroups.com
First, I'm web developer. I'm new in C# application, I've successfully added cefsharp to reference, now I'm confused how to embed cefsharp into winforms ?
Anyone can you tell me the simple code how to do that?

Gerculy Robert

unread,
Sep 14, 2013, 7:14:02 AM9/14/13
to cefs...@googlegroups.com
 public WebView web_view;
        public Form1()
        {
            InitializeComponent();
            var settings = new CefSharp.Settings
            {
                PackLoadingDisabled = true,
            };
            if (CEF.Initialize(settings))
            {
                web_view = new WebView("http://google.com", new CefSharp.BrowserSettings());
                web_view.Dock = DockStyle.Fill;
                toolStripContainer1.ContentPanel.Controls.Add(web_view);
            }

        }

Note to add toolStripContainer1 to your form.
 

Ribhararnus Pracutian

unread,
Sep 14, 2013, 7:18:29 AM9/14/13
to cefs...@googlegroups.com
This is my code Form1.cs :

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CefSharp.WinForms;
using CefSharp;

namespace WindowsFormsApplication1
{
    public partial class mainForm : Form
    {
        WebView webView;
        public mainForm()
        {
            InitializeComponent();
        }

        private void mainForm_Load(object sender, EventArgs e)
        {
            var settings = new CefSharp.Settings
            {
                PackLoadingDisabled = true,
            };

            if (CEF.Initialize(settings))
            {
                webView = new WebView("http://google.com", new CefSharp.BrowserSettings());
                webView.Dock = DockStyle.Fill;
                this.Controls.Add(webView);
            }
        }
    }
}


Sorry I'm very super noob, don't know how to develop windows application.


--
You received this message because you are subscribed to a topic in the Google Groups "CefSharp" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cefsharp/0-pbMrxTLIY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cefsharp+u...@googlegroups.com.
To post to this group, send email to cefs...@googlegroups.com.
Visit this group at http://groups.google.com/group/cefsharp.
For more options, visit https://groups.google.com/groups/opt_out.



--
-------------------------------
ribhararn.us/pracutian OknooRap, personal blog, Web design and Development
www.faktailmiah.com Indonesian Daily Science news

Gerculy Robert

unread,
Sep 14, 2013, 7:21:19 AM9/14/13
to cefs...@googlegroups.com
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CefSharp.WinForms;
using CefSharp;
namespace WindowsFormsApplication1
{
    public partial class mainForm : Form
    {
        WebView webView;
 
        public mainForm()
        {
           InitializeComponent();

            var settings = new CefSharp.Settings
            {
                PackLoadingDisabled = true,
            };
            if (CEF.Initialize(settings))
            {
                web_view = new WebView("http://plyhost.com/rv2/", new CefSharp.BrowserSettings());
                web_view.Dock = DockStyle.Fill;
                toolStripContainer1.ContentPanel.Controls.Add(web_view);
            }
        }

        private void mainForm_Load(object sender, EventArgs e)
        {
        
        }
    }
}

Here you go. 

Ribhararnus Pracutian

unread,
Sep 14, 2013, 7:26:16 AM9/14/13
to cefs...@googlegroups.com
But got error :

System.IO.FileLoadException was unhandled
  Message=Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.
  Source=WPVenom
  StackTrace:
       at WindowsFormsApplication1.mainForm..ctor()
       at WindowsFormsApplication1.Program.Main() in C:\Users\siska\documents\visual studio 2010\Projects\WPVenom\WPVenom\Program.cs:line 18
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 



--
You received this message because you are subscribed to a topic in the Google Groups "CefSharp" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cefsharp/0-pbMrxTLIY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cefsharp+u...@googlegroups.com.
To post to this group, send email to cefs...@googlegroups.com.
Visit this group at http://groups.google.com/group/cefsharp.
For more options, visit https://groups.google.com/groups/opt_out.

Gerculy Robert

unread,
Sep 14, 2013, 7:28:47 AM9/14/13
to cefs...@googlegroups.com
You have all required files in bin\Debug and/or bin\Release ?

---
icudt.dll
libcef.dll
CefSharp.dll
CefSharp.WinForms.dll
--

Ribhararnus Pracutian

unread,
Sep 14, 2013, 7:31:39 AM9/14/13
to cefs...@googlegroups.com
Yes i do, all .dll was added both Debug or Release folder, but if my code like this :


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CefSharp.WinForms;
using CefSharp;

namespace WindowsFormsApplication1
{
    public partial class mainForm : Form
    {
        public WebView webView;
        public mainForm()
        {
            InitializeComponent();
        }

        private void mainForm_Load(object sender, EventArgs e)
        {
            var settings = new CefSharp.Settings
            {
                PackLoadingDisabled = true,
            };

            webView = new WebView("http://google.com", new CefSharp.BrowserSettings());
            webView.Dock = DockStyle.Fill;
            this.Controls.Add(webView);
        }
    }
}


No error and nothing happen, just windows form appear, not google.com


--
You received this message because you are subscribed to a topic in the Google Groups "CefSharp" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cefsharp/0-pbMrxTLIY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cefsharp+u...@googlegroups.com.
To post to this group, send email to cefs...@googlegroups.com.
Visit this group at http://groups.google.com/group/cefsharp.
For more options, visit https://groups.google.com/groups/opt_out.

Ribhararnus Pracutian

unread,
Sep 14, 2013, 7:34:13 AM9/14/13
to cefs...@googlegroups.com
FYI : I'm using VS2010 Express

Gerculy Robert

unread,
Sep 14, 2013, 7:34:51 AM9/14/13
to cefs...@googlegroups.com
Use my code 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CefSharp.WinForms;
using CefSharp;

namespace PLYSOFT
{
    public partial class Form1 : Form
    {
        public WebView web_view;

        public Form1()
        {
            InitializeComponent();

            var settings = new CefSharp.Settings
            {
                PackLoadingDisabled = true,
            };
            if (CEF.Initialize(settings))

Ribhararnus Pracutian

unread,
Sep 14, 2013, 7:39:50 AM9/14/13
to cefs...@googlegroups.com
what is toolStripContainer1 ?


--
You received this message because you are subscribed to a topic in the Google Groups "CefSharp" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cefsharp/0-pbMrxTLIY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cefsharp+u...@googlegroups.com.
To post to this group, send email to cefs...@googlegroups.com.
Visit this group at http://groups.google.com/group/cefsharp.
For more options, visit https://groups.google.com/groups/opt_out.

Gerculy Robert

unread,
Sep 14, 2013, 7:44:40 AM9/14/13
to cefs...@googlegroups.com
Open From1.cs [Design], next open ToolBox and search " tool ". Should be 2nd item. Once you see it drag it into your from .

On Saturday, September 14, 2013 1:37:44 PM UTC+3, Ribhararnus Pracutian wrote:

Ribhararnus Pracutian

unread,
Sep 14, 2013, 7:49:02 AM9/14/13
to cefs...@googlegroups.com
Still, nothing happen. :D google.com doesn't appear.


--
You received this message because you are subscribed to a topic in the Google Groups "CefSharp" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cefsharp/0-pbMrxTLIY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cefsharp+u...@googlegroups.com.
To post to this group, send email to cefs...@googlegroups.com.
Visit this group at http://groups.google.com/group/cefsharp.
For more options, visit https://groups.google.com/groups/opt_out.

Ribhararnus Pracutian

unread,
Sep 14, 2013, 8:01:06 AM9/14/13
to cefs...@googlegroups.com
no errors, but not working :( 

Gerculy Robert

unread,
Sep 14, 2013, 8:03:34 AM9/14/13
to cefs...@googlegroups.com
Attach your form, I'll fix it. ( All files - zipped )


On Saturday, September 14, 2013 1:37:44 PM UTC+3, Ribhararnus Pracutian wrote:

Ribhararnus Pracutian

unread,
Sep 14, 2013, 8:46:05 AM9/14/13
to cefs...@googlegroups.com


--
You received this message because you are subscribed to a topic in the Google Groups "CefSharp" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cefsharp/0-pbMrxTLIY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cefsharp+u...@googlegroups.com.
To post to this group, send email to cefs...@googlegroups.com.
Visit this group at http://groups.google.com/group/cefsharp.
For more options, visit https://groups.google.com/groups/opt_out.

Ribhararnus Pracutian

unread,
Sep 14, 2013, 8:47:04 AM9/14/13
to cefs...@googlegroups.com
sorry that one was invalid file, I'll upload it again

Gerculy Robert

unread,
Sep 14, 2013, 8:54:54 AM9/14/13
to cefs...@googlegroups.com
Upload to dropbox or send by mail to rger...@gmail.com


On Saturday, September 14, 2013 1:37:44 PM UTC+3, Ribhararnus Pracutian wrote:

Ribhararnus Pracutian

unread,
Sep 14, 2013, 9:17:54 AM9/14/13
to cefs...@googlegroups.com
This one is correct :


Gerculy Robert

unread,
Sep 14, 2013, 9:37:52 AM9/14/13
to cefs...@googlegroups.com
Sorry but can't get it working, However,  I attach my browser, It has a few things added ( 2 menus ) you can use them or simply delete them. 
P.S. Watch out whit rename. 


On Saturday, September 14, 2013 1:37:44 PM UTC+3, Ribhararnus Pracutian wrote:

Ribhararnus Pracutian

unread,
Sep 14, 2013, 9:52:31 AM9/14/13
to cefs...@googlegroups.com
okay I'll try


--
You received this message because you are subscribed to a topic in the Google Groups "CefSharp" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cefsharp/0-pbMrxTLIY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cefsharp+u...@googlegroups.com.
To post to this group, send email to cefs...@googlegroups.com.
Visit this group at http://groups.google.com/group/cefsharp.
For more options, visit https://groups.google.com/groups/opt_out.

Ribhararnus Pracutian

unread,
Sep 14, 2013, 10:19:17 AM9/14/13
to cefs...@googlegroups.com
Thanks Gerculy, but I can't build your project :

Could not load file or assembly 'CefSharp.dll' or one of its dependencies. The specified module could not be found.

How to fix that?

Gerculy Robert

unread,
Sep 14, 2013, 10:28:31 AM9/14/13
to cefs...@googlegroups.com
I had the same problem with your project. You could try to delete CefSharp.dll from references and add it again.


On Saturday, September 14, 2013 1:37:44 PM UTC+3, Ribhararnus Pracutian wrote:

Ribhararnus Pracutian

unread,
Sep 14, 2013, 10:31:57 AM9/14/13
to cefs...@googlegroups.com
- Remove it
- Add again

Still the same :D I don't know that desktop programming is so complicated like this.


--
You received this message because you are subscribed to a topic in the Google Groups "CefSharp" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cefsharp/0-pbMrxTLIY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cefsharp+u...@googlegroups.com.
To post to this group, send email to cefs...@googlegroups.com.
Visit this group at http://groups.google.com/group/cefsharp.
For more options, visit https://groups.google.com/groups/opt_out.

Gerculy Robert

unread,
Sep 14, 2013, 10:46:24 AM9/14/13
to cefs...@googlegroups.com
Is not always that bad :P I'm new like you here, so there's nothing I can do more. Create a new project based on what I send you.
It took me 2 hours to make it work. ( after watching it for one week, I mean, I saw it was a nice framework but I have no idea how to use it) Today I decide to try again and I made it.
Don't give up :P

On Saturday, September 14, 2013 1:37:44 PM UTC+3, Ribhararnus Pracutian wrote:

Ribhararnus Pracutian

unread,
Sep 14, 2013, 10:53:49 AM9/14/13
to cefs...@googlegroups.com
Yeah :D thanks,btw how to change output 32 or 64 bit? I googling it, the main problem above is the output run at 64bit, but the output was 32 bit.


--
You received this message because you are subscribed to a topic in the Google Groups "CefSharp" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cefsharp/0-pbMrxTLIY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cefsharp+u...@googlegroups.com.
To post to this group, send email to cefs...@googlegroups.com.
Visit this group at http://groups.google.com/group/cefsharp.
For more options, visit https://groups.google.com/groups/opt_out.

Gerculy Robert

unread,
Sep 14, 2013, 11:26:53 AM9/14/13
to cefs...@googlegroups.com
Right Click on project > Build > Platform Target > x86 

This also fix sometimes errors :)

Ribhararnus Pracutian

unread,
Sep 14, 2013, 10:06:44 PM9/14/13
to cefs...@googlegroups.com
yes :( but still nothing happen, I mean still got error message :(


On Sat, Sep 14, 2013 at 10:26 PM, Gerculy Robert <rger...@gmail.com> wrote:
Right Click on project > Build > Platform Target > x86 

This also fix sometimes errors :)

--
You received this message because you are subscribed to a topic in the Google Groups "CefSharp" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cefsharp/0-pbMrxTLIY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cefsharp+u...@googlegroups.com.
To post to this group, send email to cefs...@googlegroups.com.
Visit this group at http://groups.google.com/group/cefsharp.
For more options, visit https://groups.google.com/groups/opt_out.

Gerculy Robert

unread,
Sep 15, 2013, 6:31:23 AM9/15/13
to cefs...@googlegroups.com
Which version of VS you use ? You might try 2013, Is pretty good :)

Ribhararnus Pracutian

unread,
Sep 15, 2013, 7:56:06 AM9/15/13
to cefs...@googlegroups.com
2010 :D still have the same problem like yesterday :D help me..


On Sun, Sep 15, 2013 at 5:31 PM, Gerculy Robert <rger...@gmail.com> wrote:
Which version of VS you use ? You might try 2013, Is pretty good :)

--
You received this message because you are subscribed to a topic in the Google Groups "CefSharp" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cefsharp/0-pbMrxTLIY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cefsharp+u...@googlegroups.com.
To post to this group, send email to cefs...@googlegroups.com.
Visit this group at http://groups.google.com/group/cefsharp.
For more options, visit https://groups.google.com/groups/opt_out.

Gerculy Robert

unread,
Sep 15, 2013, 8:02:47 AM9/15/13
to cefs...@googlegroups.com
Install VS 2013 and use my project. My browser is fully working. Is live : http://www.cdn.plyhost.com/browser/

Gerculy Robert

unread,
Sep 15, 2013, 8:05:22 AM9/15/13
to cefs...@googlegroups.com
Inline image 1

See image as well. 
working.png

Ribhararnus Pracutian

unread,
Sep 15, 2013, 10:59:43 AM9/15/13
to cefs...@googlegroups.com
Thanks downloading VS2013 now.
working.png

Gerculy Robert

unread,
Sep 15, 2013, 11:00:31 AM9/15/13
to cefs...@googlegroups.com
Good luck :)
working.png

Ribhararnus Pracutian

unread,
Sep 15, 2013, 11:07:59 AM9/15/13
to cefs...@googlegroups.com
Installed. still had the same problem :(

+ $exception {"Could not load file or assembly 'CefSharp.dll' or one of its dependencies. The specified module could not be found.":"CefSharp.dll"} System.Exception {System.IO.FileNotFoundException}

working.png

Gerculy Robert

unread,
Sep 15, 2013, 11:13:22 AM9/15/13
to cefs...@googlegroups.com
When you add references you add them from your bin/debug/ folder ?
working.png

Ribhararnus Pracutian

unread,
Sep 15, 2013, 11:25:24 AM9/15/13
to cefs...@googlegroups.com
Yes
working.png

Ribhararnus Pracutian

unread,
Sep 15, 2013, 11:38:01 AM9/15/13
to cefs...@googlegroups.com
:( how? why this is happen to me LOL
working.png

Gerculy Robert

unread,
Sep 16, 2013, 12:11:39 AM9/16/13
to cefs...@googlegroups.com
Solution found by Ribhararnus Pracutian >> https://github.com/cefsharp/CefSharp/issues/163

Ribhararnus Pracutian

unread,
Sep 16, 2013, 12:39:48 AM9/16/13
to cefs...@googlegroups.com
status closed :)

Chandru Raju

unread,
Nov 8, 2013, 8:45:48 AM11/8/13
to cefs...@googlegroups.com
Hey i am facing similar kind of problem...
I have tried using the cefsharp in windows application , when i run the application i am getting the error 

>>
Could not load file or assembly 'CefSharp.dll' or one of its dependencies. The specified module could not be found.
 
>> 
 
But i have referenced the latest version of the cefsharp(1.25.5.0) also i have add the supporting assemblies to the bin folder of my working directory 
 

i even tired google but dint got any info 
"https://groups.google.com/forum/#!topic/cefsharp/d-mwn831Bm0"
 
i am using visual studio 2010 with .net-framework 4.0
 

Could you suggest me what can be done to resolve the issue ?

Ribhararnus Pracutian

unread,
Nov 8, 2013, 9:26:11 PM11/8/13
to cefs...@googlegroups.com
add msvcp110.dll, msvcr110.dll, vccorlib110.dll into your build folder.

Chandru Raju

unread,
Nov 14, 2013, 9:58:22 AM11/14/13
to cefs...@googlegroups.com
works fine  thank you 
Reply all
Reply to author
Forward
0 new messages