diff --git a/src/Compilers/Core/Portable/InternalUtilities/FatalError.cs b/src/Compilers/Core/Portable/InternalUtilities/FatalError.cs index 37e423cf13e1c..262e9fabf9326 100644 --- a/src/Compilers/Core/Portable/InternalUtilities/FatalError.cs +++ b/src/Compilers/Core/Portable/InternalUtilities/FatalError.cs @@ -76,11 +76,11 @@ public static void CopyHandlersTo(Assembly assembly) static void copyHandlerTo(Assembly assembly, ErrorReporterHandler? handler, string handlerName) { var targetType = assembly.GetType(typeof(FatalError).FullName!, throwOnError: true)!; - var targetHandlerProperty = targetType.GetProperty(handlerName, BindingFlags.Static | BindingFlags.NonPublic)!; + var targetHandlerProperty = targetType.GetField(handlerName, BindingFlags.Static | BindingFlags.NonPublic)!; if (handler is not null) { // We need to convert the delegate type to the type in the linked copy since they won't have identity. - var convertedDelegate = Delegate.CreateDelegate(targetHandlerProperty.PropertyType, handler.Target, handler.Method); + var convertedDelegate = Delegate.CreateDelegate(targetHandlerProperty.FieldType, handler.Target, handler.Method); targetHandlerProperty.SetValue(obj: null, value: convertedDelegate); } else