dotnet/wpf · error · XamlSchemaException

SR.BadInternalsVisibleTo1

Error message

SR.BadInternalsVisibleTo1

What it means

LoadInternalsVisibleToHelper throws this XamlSchemaException when an InternalsVisibleToAttribute on the assembly has a null AssemblyName, making the attribute unparseable while collecting friend-assembly names for XAML schema context. The attribute data itself is corrupt.

Solutions

  1. Ensure the assembly's InternalsVisibleToAttribute has a valid AssemblyName string
  2. Fix the [assembly: InternalsVisibleTo(...)] declaration in the friend assembly
  3. Verify the attribute value parses as an AssemblyName
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/MS/Impl/XmlNsInfo.cs:283 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/MS/Impl/XmlNsInfo.cs:283

            }
            else
            {
                Attribute[] attributes = Attribute.GetCustomAttributes(assembly, typeof(InternalsVisibleToAttribute));
                for (int i = 0; i < attributes.Length; i++)
                {
                    InternalsVisibleToAttribute ivAttrib = (InternalsVisibleToAttribute)attributes[i];
                    LoadInternalsVisibleToHelper(result, ivAttrib.AssemblyName, assembly);
                }
            }

            return result;
        }

        private void LoadInternalsVisibleToHelper(List<AssemblyName> result, string assemblyName, Assembly assembly)
        {
            if (assemblyName is null)
            {
                throw new XamlSchemaException(SR.Format(SR.BadInternalsVisibleTo1, assembly.FullName));
            }

            try
            {
                result.Add(new AssemblyName(assemblyName));
            }
            catch (ArgumentException ex)
            {
                throw new XamlSchemaException(SR.Format(SR.BadInternalsVisibleTo2, assemblyName, assembly.FullName), ex);
            }

            // AssemblyName.ctor throws FLE on malformed assembly name
            catch (FileLoadException ex)
            {
                throw new XamlSchemaException(SR.Format(SR.BadInternalsVisibleTo2, assemblyName, assembly.FullName), ex);
            }
        }

View on GitHub (pinned to 81131a70a4)