I'm having a rough go of it getting started. First, I tried using the NuGet package(s). When I installed them none of the necessary references to the CefSharp DLLs showed up in my References list. So I added them by hand by searching the /packages sub-directory. After getting my project to build, I discovered that when I executed a URL load nothing happened. No web page loaded, no error messages, no exceptions triggered. Nothing.
I removed the CefSharp Nuget package(s) completely and pulled down the latest repo source from GitHub. I first made sure that the URL load worked fine from the CefSharp.WinForms.Example project. It worked great. I then copied the necessary set of projects from the CefSharp solution into my project's solution until I had my solution build properly. I added the BrowserForm form from the CefSharp.WinForms.Example project to make sure it wasn't my code. However, when I open that form at run-time, enter a URL into the address bar, and click the Go button nothing happens. Just like before.
I traced out the code and found the failure point in this C++ method in ManagedCefBrowserAdapter.h:
void LoadUrl(String^ address)
{
_address = address;
auto cefFrame = _renderClientAdapter->TryGetCefMainFrame();
// This is where cefFrame is treated qual to nullptr despite
// having the value of {CefRefPtr<CefFrame>}, thereby defeating
// the call to LoadURL().
if (cefFrame != nullptr)
{
cefFrame->LoadURL(StringUtils::ToNative(address));
}
}
It turns out that there's a really strange problem. When I trace the code up to the "if" statement I see that value of cefFrame is:
{CefRefPtr<CefFrame>}
However, it apparently is not NULL and yet it is being teated as if it is. (Or my analysis of the {CefRefPtr} value is wrong and so is my analysis.)
In either case the "if" statement treats the current value of cefFrame as equal to nullptr and skips over the line that calls the LoadURL() method on the cefFrame referenced object. I trace this exact same code while in my copy of the GitHub CefSharp repo's solution and it does enter the "if" block and execute the LoadURL() method. I checked the value of cefFrame and it is the same as the value I have in my app. For some truly odd reason either there's a more insidious problem here or in my app, or it really does treat cefFrame's value of {CefRefPtr} the same as nullptr's when it shouldn't.
I would really appreciate it if anyone has any idea on how I can get things working in my code.
UPDATE: I triple-checked and the Build Configurations are identical between the GitHub CefSharp solution that does work and my project that doesn't. Everything is set to x86 except for the Core project which are set to Win32 (in both case).
I just did a rebuild and on top of that I went through each included project and manually deleted both the /bin and /obj directories completely. Now when I run the project something different is happening. Whenever I the code attempts to create a new BrowserTabUserControl, I get an Unhandled Exception:
System.IO.FileNotFoundException was unhandled
_HResult=-2147024770
_message=Could not load file or assembly 'CefSharp.Core.dll' or one of its dependencies. The specified module could not be found.
HResult=-2147024770
IsTransient=false
Message=Could not load file or assembly 'CefSharp.Core.dll' or one of its dependencies. The specified module could not be found.
Source=HiveMind3D_proto
FileName=CefSharp.Core.dll
FusionLog=""
StackTrace:
at HiveMind3D_proto.BrowserTabUserControl..ctor(String url)
at HiveMind3D_proto.BrowserForm.AddTab(String url, Nullable`1 insertIndex) in c:\Users\Robert\Documents\Visual Studio 2012\Projects\Windows Forms\HiveMind3D_proto\HiveMind3D_proto\BrowserForm.cs:line 35
at HiveMind3D_proto.BrowserForm..ctor() in c:\Users\Robert\Documents\Visual Studio 2012\Projects\Windows Forms\HiveMind3D_proto\HiveMind3D_proto\BrowserForm.cs:line 24
at HiveMind3D_proto.Program.Main() in c:\Users\Robert\Documents\Visual Studio 2012\Projects\Windows Forms\HiveMind3D_proto\HiveMind3D_proto\Program.cs:line 26
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.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
I tried removing the CefSharp.Core project reference in the main project and re-adding it by re-adding a reference to the CefSharp.Core project. But I still get that Exception.