cefsharp/CefSharp · error · ArgumentNullException
fieldInfo
Error message
fieldInfo
What it means
Thrown by the BindingMemberInfo(FieldInfo) constructor when fieldInfo is null. Like the PropertyInfo overload, the constructor reads FieldType/Name from the argument, so the guard fails fast with ArgumentNullException naming 'fieldInfo' instead of letting a null slip through to a later NullReferenceException.
Source
Thrown at CefSharp/ModelBinding/BindingMemberInfo.cs:54
{
throw new ArgumentNullException("propertyInfo");
}
memberInfo = propertyInfo;
Type = propertyInfo.PropertyType;
Name = propertyInfo.Name;
}
/// <summary>
/// Constructs a BindingMemberInfo instance for a field.
/// </summary>
/// <param name="fieldInfo">The bindable field to represent.</param>
public BindingMemberInfo(FieldInfo fieldInfo)
{
if (fieldInfo == null)
{
throw new ArgumentNullException("fieldInfo");
}
memberInfo = fieldInfo;
Type = fieldInfo.FieldType;
Name = fieldInfo.Name;
}
/// <summary>
/// Sets the value from a specified object associated with the property or field represented by this BindingMemberInfo.
/// </summary>
/// <param name="destinationObject">The object whose property or field should be assigned.</param>
/// <param name="newValue">The value to assign in the specified object to this BindingMemberInfo's property or field.</param>
public void SetValue(object destinationObject, object newValue)
{
if (memberInfo is PropertyInfo)
{
((PropertyInfo)memberInfo).SetValue(destinationObject, newValue, null);View on GitHub (pinned to 16bc6e0711)
Solutions
- Null-check the FieldInfo (from Type.GetField) before constructing BindingMemberInfo.
- Confirm the field name/casing used in reflection.
- Use nameof() to keep reflection lookups bound to real members.
- Throw a clear error at the reflection site when the field is absent.
Example fix
// before
var fi = type.GetField("Flag"); // field renamed -> null
var bm = new BindingMemberInfo(fi);
// after
var fi = type.GetField(nameof(MyVm.Flag));
if (fi == null) throw new InvalidOperationException("Field not found on " + type);
var bm = new BindingMemberInfo(fi); Defensive patterns
Strategy: type-guard
Validate before calling
var fi = type.GetField(nameof(MyVm.Flag));
if (fi == null) throw new InvalidOperationException("Field not found on " + type.FullName);
var bm = new BindingMemberInfo(fi); Type guard
static bool TryCreate(FieldInfo fi, out BindingMemberInfo bm) {
bm = fi == null ? default : new BindingMemberInfo(fi); return fi != null; } Try / catch
try { var bm = new BindingMemberInfo(fi); }
catch (ArgumentNullException ex) when (ex.ParamName == "fieldInfo")
{ /* reflection miss; log and skip member */ } Prevention
- Null-check reflection results before constructing.
- Use nameof() for field lookups.
- Throw a descriptive error at the reflection site.
When it happens
Trigger: Passing a FieldInfo from Type.GetField that returned null (misspelled or non-existent field name), or a nullable expression without a prior null check.
Common situations: Reflecting over a field name that does not exist; class refactor removing the field; binding filter passing a null upstream.
Related errors
AI-assisted analysis of cefsharp/CefSharp@16bc6e0711 (2026-08-13).
Data as JSON: /api/errors/c1f5b3aaf588ff70.
Report an issue: GitHub.