F# attributes, typeof, and “This is not a constant expression”
问题 EDIT: Added a more complete example, which clarified the problem. Some .NET attributes require a parameter of type Type . How does one declare these parameters in F#? For example, in C# we can do this: [XmlInclude(typeof(Car))] [XmlInclude(typeof(Truck))] class Vehicle { } class Car : Vehicle { } class Truck : Vehicle { } But, in F# the following... [<XmlInclude(typeof<Car>)>] [<XmlInclude(typeof<Truck>)>] type Vehicle() = class end type Car() = inherit Vehicle() type Truck() = inherit Car()