The Compiler Error CS0735 is a configuration error related to Type Forwarding. The message reads: "Invalid type specified as an argument for TypeForwardedTo attribute".
Type Forwarding is a mechanism used to move a type from one assembly to another without breaking existing applications that reference it. You leave a "signpost" attribute ([TypeForwardedTo]) in the old assembly pointing to the new location. However, this attribute strictly requires a valid, fully defined type (a System.Type object). This error occurs when you pass something that is not a valid type definition, such as a generic open type without the proper syntax, or a type that cannot be resolved in the current context.
This guide explains the correct syntax for forwarding types.
Understanding Type Forwarding Arguments
The [TypeForwardedTo] attribute signature looks like this:
public TypeForwardedToAttribute(Type destination)
It expects a System.Type object. In C#, you obtain this using the typeof() operator.
- Valid:
typeof(MyClass),typeof(List<int>),typeof(List<>). - Invalid:
MyClass(without typeof),List<>(raw syntax), or0(null/invalid inputs).
CS0735 usually indicates a syntax error inside the attribute parentheses where the compiler expected a type token but found something else.
Scenario: Forwarding Generic Types Incorrectly
This error is most common when forwarding Generic Types. Developers often struggle with the syntax for "Open Generics" (a generic type without specific arguments, like List<T>).
Example of error: attempting to forward a generic type using invalid syntax inside typeof.
using System.Runtime.CompilerServices;
// ⛔️ Error CS0735: Invalid type specified.
// You cannot use 'typeof(MyGenericClass<T>)' here because 'T' is not defined.
// You also cannot simply write 'MyGenericClass' if it requires type parameters.
[assembly: TypeForwardedTo(typeof(MyGenericClass<T>))]
namespace OldAssembly
{
// The class definition has been moved to another assembly.
}Solution: Use typeof Correctly
To fix this, you must use the correct C# syntax for obtaining a type token.
Forwarding a Standard Class
Simply wrap the class name in typeof().
using System.Runtime.CompilerServices;
// ✅ Correct: Standard type forwarding
[assembly: TypeForwardedTo(typeof(MyMovedClass))]Forwarding an Open Generic Class
If you are forwarding public class MyGeneric<T>, use the "unbound" syntax with empty angle brackets.
using System.Runtime.CompilerServices;
// ✅ Correct: The empty brackets '<>' represent the open generic definition.
[assembly: TypeForwardedTo(typeof(MyGenericClass<>))]Forwarding a Multi-Parameter Generic
If the class is MyMap<TKey, TValue>, use commas to indicate the number of parameters.
using System.Runtime.CompilerServices;
// ✅ Correct: One comma means two parameters.
[assembly: TypeForwardedTo(typeof(MyMap<,>))]Conclusion
CS0735 is a syntax check on the attribute argument.
- Check the Operator: Ensure you are using
typeof(...). - Check Generics:
- Do not put
Tinside the brackets. - Use
<>forList<T>. - Use
<,>forDictionary<K,V>.
- Do not put