dotnet / dotnet/wpf

PrintServer.GetPrintQueues throws NullReferenceException

Open
#8,339 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

### 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.