dotnet/wpf · error · ArgumentException
Transform object type is required to implement…
Error message
Transform object type is required to implement IDataTransform interface.
What it means
After instantiating a transform object, InstantiateDataTransformObject verifies the instance implements IDataTransform. Although in current code both predefined transforms always implement it, the defensive check throws ArgumentException with SR.TransformObjectImplementIDataTransform if the created object does not satisfy the interface contract.
Solutions
- Ensure every transform class instantiated in the identifier switch implements IDataTransform.
- Run the transform class through a compile-time check (implement the interface explicitly) before registering it as a predefined identifier.
- Catch ArgumentException and log the offending transform class name to identify the non-conforming implementation.
- Add a unit test asserting each predefined transform type is assignable to IDataTransform.
Example fix
// before
class MyTransform { /* no IDataTransform */ }
// after
class MyTransform : IDataTransform
{
public TransformMinorVersionCollection MinorVersions => ...;
// implement interface members
} Defensive patterns
Strategy: validation
Validate before calling
// compile-time/unit check for custom predefined transforms Assert(typeof(RightsManagementEncryptionTransform).IsAssignableTo(typeof(IDataTransform))); Assert(typeof(CompressionTransform).IsAssignableTo(typeof(IDataTransform)));
Type guard
bool ImplementsDataTransform(object t) => t is IDataTransform;
Prevention
- Make every transform class implement IDataTransform explicitly.
- Add a unit test asserting all predefined transform types satisfy the interface.
When it happens
Trigger: InstantiateDataTransformObject constructed a transformInstance that is not castable to IDataTransform — a programming/invariant failure inside a custom or modified transform implementation (e.g. someone swapped in a transform class missing the interface). Under stock WindowsBase this is effectively unreachable; it fires when the transform class implementations are altered.
Common situations: Custom builds or forks of WindowsBase where a new predefined transform class was added to the identifier switch but does not implement IDataTransform; refactoring that dropped the interface from a transform class; unit tests substituting fake transform objects.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Transform identifier type is not supported.
- Data space transform stack includes undefined transform…
- DataSpace map entry is not valid.
- File contains corrupted data.
- File contains data in format version
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/718e2164f68276e0.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/CompoundFile/DataSpaceManager.cs:740
if (string.Equals(transformClassName, RightsManagementEncryptionTransform.ClassTransformIdentifier, StringComparison.OrdinalIgnoreCase))
{
transformInstance = new RightsManagementEncryptionTransform( transformEnvironment);
}
else if (string.Equals(transformClassName, CompressionTransform.ClassTransformIdentifier, StringComparison.OrdinalIgnoreCase))
{
transformInstance = new CompressionTransform( transformEnvironment );
}
else
{
//this transform class is not supported. Need to change this to appropriate error.
throw new ArgumentException(
SR.TransformLabelUndefined);
}
if (null != transformInstance)
{
if( !( transformInstance is IDataTransform ) )
throw new ArgumentException(
SR.TransformObjectImplementIDataTransform);
return (IDataTransform)transformInstance;
}
return null;
}
/// <summary>
/// Private method to check if a transform label is defined. When we
/// start reading transform defintions on-demand, we would probably do it
/// here as necessary.
/// </summary>
/// <param name="transformLabel">Transform label to check</param>
/// <returns>True if label is defined in hash table</returns>
internal bool TransformLabelIsDefined( string transformLabel )
{
// Idea: When we start reading transform definitions on-demand,
// be able to check this without hitting the disk.View on GitHub (pinned to 81131a70a4)