Skip to content

ObjectDisposedException when accessing bound object on certain sites #5275

Description

@jsoldi

Is there an existing issue for this?

  • I have searched both open/closed issues, no issue already exists.

CefSharp Version

150

Operating System

Windows 11

Architecture

x64

.Net Version

4.7.2

Implementation

WinForms

Reproduction Steps

  1. Clone https://github.com/jsoldi/CefSharp
  2. Launch CefSharp.WinForms.Example
  3. Select from main menu Test -> Hello
  4. Wait a few seconds and see debug console output

Expected behavior

Script should return a value without failing

Actual behavior

An error occurs:

Uncaught Error: System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.ServiceModel.Channels.ServiceChannel'.

Server stack trace: 
   at System.ServiceModel.Channels.CommunicationObject.ThrowIfDisposedOrNotOpen()
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at CefSharp.Internals.Wcf.IBrowserProcess.CallMethod(Int64 objectId, String name, Object[] parameters)
   at CefSharp.BrowserSubprocess.JavascriptMethodWrapper.Execute(Object[] parameters) in C:\Users\jsold\Desktop\CefSharp\CefSharp\CefSharp.BrowserSubprocess.Core\JavascriptMethodWrapper.cpp:line 26
   at CefSharp.BrowserSubprocess.JavascriptMethodHandler.Execute(JavascriptMethodHandler* , CefStringBase<CefStringTraitsUTF16>* name, scoped_refptr<CefV8Value>* object, vector<scoped_refptr<CefV8Value>\,std::allocator<scoped_refptr<CefV8Value> > >* arguments, scoped_refptr<CefV8Value>* retval, CefStringBase<CefStringTraitsUTF16>* exception) in C:\Users\jsold\Desktop\CefSharp\CefSharp\CefSharp.BrowserSubprocess.Core\JavascriptMethodHandler.cpp:line 25
@ about:blank:1:6

Regression?

No response

Known Workarounds

No response

Does this problem also occur in the CEF Sample Application

Yes on the WinForms example. I have also had this error on headless mode but don't have replication steps.

Other information

I'm sure this bug is related to #4621 which is marked as closed. It occurs in the exact same pages and situations in which that error occurred on previous versions. The only difference is that in the new version the error message has changed from "Request BrowserId : 1 not found it's likely the browser is already closed" to an ObjectDisposedException.

The error only seems to occur when LegacyBindingEnabled is true. I don't know where the proper place to set this property is in the WinForms example project so I just set it on BrowserTabUserControl.cs. I only made a few changes to the fork which I updated from the master CefSharp repo a few minutes ago. The changes I made are here all one commit: jsoldi@55732f0

I haven't found any other URL in which this error occurs than the one on my test, but it seems to me that the bug was fixed for non-legacy binding but not for legacy. I need legacy binding so the object is available before the page completes loading. If I recall correctly, non-legacy binding only adds the object after the page has loaded.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions