dotnet/wpf · error · ProxyAssemblyNotLoadedException

SR.CouldNotFindRegisterMethodOnType0InAssembly1 (formatted…

Error message

SR.CouldNotFindRegisterMethodOnType0InAssembly1 (formatted with typeName, assemblyName)

What it means

RegisterProxyAssembly expects the 'UIAutomationClientSideProviders' type to expose a public static field named ClientSideProviderDescriptionTable of type ClientSideProviderDescription[]. If the field is missing or has the wrong type, it throws ProxyAssemblyNotLoadedException with SR.CouldNotFindRegisterMethodOnType0InAssembly1 (message text notwithstanding, the check is the field lookup).

Solutions

  1. Add the exact field: public static ClientSideProviderDescription[] ClientSideProviderDescriptionTable = new ClientSideProviderDescription[] { ... };
  2. Ensure the field is public and static (BindingFlags.Static | BindingFlags.Public lookup fails for internal/instance members).
  3. Ensure the field type is exactly ClientSideProviderDescription[] (not a derived/base array).

Example fix

// before
internal static object[] ClientSideProviderDescriptionTable = ...;
// after
public static UIAutomationClientSideProviders.ClientSideProviderDescriptionTable =>
    // actually a field, not a property:
public static ClientSideProviderDescription[] ClientSideProviderDescriptionTable =
    new ClientSideProviderDescription[] { new ClientSideProviderDescription(FactoryCallback, null, "MyClassName", ClientSideProviderMatchFlags.None) };
Defensive patterns

Strategy: validation

Validate before calling

var t = asm.GetType(asm.GetName().Name + ".UIAutomationClientSideProviders");
var f = t?.GetField("ClientSideProviderDescriptionTable", BindingFlags.Public | BindingFlags.Static);
bool ok = f != null && f.FieldType == typeof(ClientSideProviderDescription[]);

Type guard

static bool HasProviderTable(Type t) =>
  t?.GetField("ClientSideProviderDescriptionTable", BindingFlags.Public | BindingFlags.Static) is FieldInfo fi && fi.FieldType == typeof(ClientSideProviderDescription[]);

Try / catch

try { ClientSettings.RegisterClientSideProviders(table); }
catch (ProxyAssemblyNotLoadedException ex) { log.Error($"Provider table missing or wrong type: {ex.Message}"); }

Prevention

When it happens

Trigger: Registering a proxy assembly whose provider type does not declare: public static ClientSideProviderDescription[] ClientSideProviderDescriptionTable; or declares it with a different element type / as a property or internal field.

Common situations: Hand-rolled proxy assemblies that renamed the field, used a property instead of a static public field, or typed the array incorrectly (e.g., object[]); partial copies of sample proxy code.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14). Data as JSON: /api/errors/a6c5f34805a80c28. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/MS/Internal/Automation/ProxyManager.cs:70

            {
                a = Assembly.Load( assemblyName );
            }
            catch(System.IO.FileNotFoundException)
            {
                throw new ProxyAssemblyNotLoadedException(SR.Format(SR.Assembly0NotFound,assemblyName));
            } 
            
            string typeName = assemblyName.Name + ".UIAutomationClientSideProviders";
            Type t = a.GetType( typeName );
            if( t == null )
            {
                throw new ProxyAssemblyNotLoadedException(SR.Format(SR.CouldNotFindType0InAssembly1, typeName, assemblyName));
            }

            FieldInfo fi = t.GetField("ClientSideProviderDescriptionTable", BindingFlags.Static | BindingFlags.Public);
            if (fi == null || fi.FieldType !=  typeof(ClientSideProviderDescription[]))
            {
                throw new ProxyAssemblyNotLoadedException(SR.Format(SR.CouldNotFindRegisterMethodOnType0InAssembly1, typeName, assemblyName));
            }

            ClientSideProviderDescription[] table = fi.GetValue(null) as ClientSideProviderDescription[];
            if (table != null)
            {
                ClientSettings.RegisterClientSideProviders(table);
            }
        } 
        
        // register specified proxies
        internal static void RegisterWindowHandlers(ClientSideProviderDescription[] proxyInfo)
        {
            // If a client registers a proxy before the defaults proxies are loaded because of use, 
            // we should load the defaults first.
            LoadDefaultProxies();
            
            lock (_lockObj)
            {

View on GitHub (pinned to 81131a70a4)