dotnet/wpf · error · IOException
SR.StreamNotExist
Error message
SR.StreamNotExist
What it means
Thrown by StorageInfo.GetStreamInfo when the requested named stream does not exist in this storage. It is the strict variant: unlike TryGetStreamInfo-style paths, an absent stream name is treated as a hard failure with IOException rather than returning null.
Solutions
- Check StreamExists(streamName) before calling GetStreamInfo
- Confirm the file is a valid OLE compound file with the expected package layout (e.g. open with EncryptedPackageEnvelope/XpsDocument rather than raw StorageInfo)
- Fix the stream name; note internal streams start with the '\u0006' prefix
- Create the stream first via CreateStream if your code is responsible for populating it
Example fix
// before
var si = storage.GetStreamInfo(versionStreamName);
// after
if (storage.StreamExists(versionStreamName))
{
var si = storage.GetStreamInfo(versionStreamName);
}
else
{
throw new InvalidDataException($"Stream '{versionStreamName}' missing; not a valid package");
} Defensive patterns
Strategy: validation
Validate before calling
if (!storage.StreamExists(streamName)) throw new FileNotFoundException($"Stream '{streamName}' not found in storage"); Type guard
StreamInfo TryGetStream(StorageInfo s, string name) => s.StreamExists(name) ? s.GetStreamInfo(name) : null;
Try / catch
try { var si = storage.GetStreamInfo(name); }
catch (IOException ex) { /* treat as missing stream; log name and file */ } Prevention
- Prefer StreamExists checks before strict GetStreamInfo lookups
- Remember internal streams are '\u0006'-prefixed
- Verify the file actually is the expected package format before reading fixed stream names
When it happens
Trigger: Calling GetStreamInfo(streamName) for a stream name that was never created in the storage, or after the stream was deleted via DestroyElement/Delete.
Common situations: Reading well-known compound-file streams ('\u0006DataSpaces/DataSpaceMap', version stream, content stream) from a file that is not actually an XPS/RM package or has a different internal layout; typos in stream names including the '\u0006'-prefixed internal names.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- SR.StorageNotExist
- A read or write operation references a location outside the…
- Cannot access Stream object because it was closed or…
- Cannot change content of read-only stream.
- Cannot set seek pointer to a negative position.
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/351c256714bc50b4.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/CompoundFile/StorageInfo.cs:384
/// Returns the streaminfo by the passed name.
/// </summary>
/// <param name="name">Name of stream</param>
/// <returns>Reference to the stream</returns>
public StreamInfo GetStreamInfo(string name)
{
CheckDisposedStatus();
//check the arguments
ArgumentNullException.ThrowIfNull(name);
StreamInfo streamInfo = new StreamInfo(this, name);
if (streamInfo.InternalExists())
{
return streamInfo;
}
else
{
throw new IOException(SR.StreamNotExist);
}
}
/// <summary>
/// Check if the stream exists.
/// </summary>
/// <param name="name">Name of stream</param>
/// <returns>True if exists, False if not</returns>
public bool StreamExists(string name)
{
CheckDisposedStatus();
bool streamExists = false;
StreamInfo streamInfo = new StreamInfo(this, name);
streamExists = streamInfo.InternalExists();
return streamExists;View on GitHub (pinned to 81131a70a4)