Skip to content

NullReferenceException when viewing "CLSIDs by Local Server" #55

@nevul37

Description

@nevul37

Environment

Windows 11 Insider Preview 10.0.28020.1495

Description

When selecting "CLSIDs by Local Server" in the registry viewer, the list fails to load and nothing is displayed. This is caused by a NullReferenceException that occurs when the application encounters local services with a null ImagePath.

I have modified Forms\COMRegistryViewer.cs to handle null values safely.

  1. Update COMCLSIDServerEqualityComparer to handle null Server strings safely.
  2. Ensure ImagePath is converted to an empty string if it is null before creating a COMCLSIDServerEntry.
// In Forms\COMRegistryViewer.cs

// 1. Update COMCLSIDServerEqualityComparer
private class COMCLSIDServerEqualityComparer : IEqualityComparer<COMCLSIDServerEntry>
{
    public bool Equals(COMCLSIDServerEntry x, COMCLSIDServerEntry y)
    {
        // Use static string.Equals to handle nulls
        return string.Equals(x.Server, y.Server, StringComparison.OrdinalIgnoreCase);
    }

    public int GetHashCode(COMCLSIDServerEntry obj)
    {
        // Handle null Server property
        return (obj.Server ?? string.Empty).ToLower().GetHashCode();
    }
}

// 2. Update LoadCLSIDByServer method
// ... inside the loop ...
if (!string.IsNullOrEmpty(local_service.ServiceDll))
{
    curr_server = new COMCLSIDServerEntry(COMServerType.LocalServer32, local_service.ServiceDll);
}
else
{
    // Coalesce null ImagePath to empty string
    curr_server = new COMCLSIDServerEntry(COMServerType.LocalServer32, local_service.ImagePath ?? string.Empty);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions