1
Vote

Issue destroying and recreating WebCore

description

I have a c# WinForms application that launches multiple forms that house a browser. I have successfully got Awesomium 1.6 RC1 to work along with AwesomiumDotNet. However I can only create it once. When I close the first form and open a new one my "webcore" variable is always null and its "IsDisposed" property is true.
 
WebCoreConfig config = new WebCoreConfig();
config.SetLogLevel(AwesomiumDotNet.LogLevel.None);
config.SetEnablePlugins(true);
 
webcore = new WebCore(config);
webview = webcore.CreateWebView(pictureBox1.Width, pictureBox1.Height);
 
Everything works fine the first time through, however I get an exception on the CreateWebView() call after closing and reopening the form. Everything is Disposed and closed properly and I've even gone to the extreme of trying to call GC.Collect() but it did not change the results.
 
The error I get is a NullReferenceException.
 
(I am using Win7 x64)
 
 
Thanks,
 
-Dusty

comments

anthrax11 wrote Oct 7, 2010 at 4:18 PM

There's some problem with the cleanup code. The Awesomium WebCore is a singleton, so it's a bit difficult to make it compatible with C#-style disposal.
I'll try to find a solution.

Thanks for reporting!

anthrax11 wrote Oct 7, 2010 at 6:28 PM

You may want to share the WebCore instance between the forms so there's just one WebCore per application instance.

drowe wrote Oct 7, 2010 at 7:24 PM

Using a single instance is what I have done as the work around for the time being...honestly I'm not sure what would be best performance wise but am using the work-around successfully for the time being. The library that uses Awesomium is itself used by 2 different applications. So the only draw back is that now each of those applications now must manually Dispose of the WebCore in their FormClosing handler (or else another Exception will be thrown on exit of the app)...which then means that each of those applications now have to reference AwesomiumDotNet explicitly. I would have liked to not have to set an explicit reference like this and instead let my library be the only thing to reference AwesomiumDotNet.

anthrax11 wrote Nov 15, 2010 at 6:56 PM

RC2 is out and I made some changes to the cleanup code, so can you try this again?

wrote Feb 14, 2013 at 1:38 AM