cefsharp/CefSharp · info · Exception
This is an exception coming from C#
Error message
This is an exception coming from C#
What it means
This is a deliberately-thrown exception in the CefSharp.Example AsyncBoundObject.Error() method — demo code that shows how a C# method bound to JavaScript propagates exceptions back to JS. It is not a production error; it exists so the test suite and example pages can verify the error-handling pipeline between C# and JS.
Source
Thrown at CefSharp.Example/JavascriptBinding/AsyncBoundObject.cs:24
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using CefSharp.Web;
namespace CefSharp.Example.JavascriptBinding
{
public class AsyncBoundObject
{
//We expect an exception here, so tell VS to ignore
[DebuggerHidden]
public void Error()
{
throw new Exception("This is an exception coming from C#");
}
//We expect an exception here, so tell VS to ignore
[DebuggerHidden]
public int Div(int divident, int divisor)
{
return divident / divisor;
}
public string DivWithBlockingTaskCall(int dividend, int divisor)
{
var taskToWaitOn = ExecuteTaskBeforeDivision(dividend, divisor);
taskToWaitOn.Wait();
return taskToWaitOn.Result;
}
private async Task<string> ExecuteTaskBeforeDivision(int dividend, int divisor)
{View on GitHub (pinned to 16bc6e0711)
Solutions
- This is expected behavior in the example — do not treat it as a real bug.
- If you copied AsyncBoundObject into your app, remove or replace the Error() method.
- Use try/catch in JavaScript (await obj.error()) to handle bound-object exceptions in your own binding code.
Example fix
// JavaScript caller
// before
await CefSharp.BindObjectAsync('asyncBoundObj');
await asyncBoundObj.error();
// after
try { await asyncBoundObj.error(); }
catch (e) { console.log('C# exception:', e); } Defensive patterns
Strategy: try-catch
Try / catch
// In JavaScript
try { await asyncBoundObj.error(); }
catch (e) { console.log('Handled expected C# error:', e); } Prevention
- Recognize this as intentional example code — do not ship AsyncBoundObject.Error().
- Remove example bound objects from production projects.
- Always try/catch JS calls to bound C# methods.
When it happens
Trigger: Calling the bound object's Error() method from JavaScript (e.g. CefSharp.AsyncBoundObj.error()). Triggered only in the example browser app.
Common situations: Running the CefSharp.Example project and invoking the test button/handler that calls this bound method. Not encountered in production apps that don't reference AsyncBoundObject.
Related errors
- Expected Exception
- Nested Exception Invalid
- Nested Exception Canceled
- An IFrame instance is required.
- Unable to find parent TabPage
AI-assisted analysis of cefsharp/CefSharp@16bc6e0711 (2026-08-13).
Data as JSON: /api/errors/a5d09b9c9da134c9.
Report an issue: GitHub.