Skip to content

PrintServer.GetPrintQueues throws NullReferenceException #8339

@wstaelens

Description

@wstaelens

Description

when calling GetPrintQueues I sometimes get a NullReferenceException (not always)

Reproduction Steps

          var server = new System.Printing.PrintServer();
        var queues = server.GetPrintQueues(new[] { EnumeratedPrintQueueTypes.Local, EnumeratedPrintQueueTypes.Connections });

Expected behavior

never having a nullreference exception

Actual behavior

sometimes (don't know how to reproduce it) I get a NullReferenceException. (feels like it happens the first time something needs to be initialised.)

Regression?

No response

Known Workarounds

No response

Impact

No response

Configuration

.net 7 latest
windows 10 x64 22h2
vs2022 pro any cpu

Other information

when looking at https://github.com/dotnet/wpf/blob/main/src/Microsoft.DotNet.Wpf/src/System.Printing/ref/System.Printing.cs#L393 I see that it throws null, but I have print queues as a result, sometimes it throws null, but don't know why exactly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions