CefSharp upgrade and getting unhandled exception Cannot pass a GCHandle across AppDomains #4719
Replies: 1 comment 2 replies
-
Running No official release of |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We have been utilizing CefSharp version 71 for approximately four years and recently made the decision to upgrade to version 120. While implementing the required modifications, we encountered an unhandled exception during the initialization of Cef (Cef.Initialize), specifically stating 'Cannot pass a GCHandle across AppDomains.' Despite having come across articles in the past discussing the same 'Cannot pass a GCHandle across AppDomains' exception with CefSharp, we have not yet found a suitable solution.
Adding the in-depth error for reference:
System.ArgumentException
HResult=0x80070057
Message=Cannot pass a GCHandle across AppDomains.
Parameter name: handle
Source=mscorlib
StackTrace:
at System.Runtime.InteropServices.GCHandle.InternalCheckDomain(IntPtr handle)
at System.Runtime.InteropServices.GCHandle.FromIntPtr(IntPtr value)
at gcroot<System::Collections::Generic::IEnumerable<CefSharp::CefCustomScheme ^> ^>..P$AAU?$IEnumerable@P$AAVCefCustomScheme@CefSharp@@@Generic@Collections@System@@(gcroot<System::Collections::Generic::IEnumerable<CefSharp::CefCustomScheme ^> ^>* )
at CefSharp.Internals.CefSharpApp.OnContextInitialized(CefSharpApp* )
Was able to reproduce the issue in a sample app. Sample code that can be added while initializing cef to reproduce the issue.
try
{
AppDomain domain = AppDomain.CreateDomain("another domain");
CrossAppDomainDelegate action = () => { Cef.Initialize(new CefSettings()); };
domain.DoCallBack(action);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
We would greatly appreciate assistance in comprehending and resolving this issue.
Beta Was this translation helpful? Give feedback.
All reactions