Closed
Description
On the full framework, WCF looks for any attributes declared on a type where the attribute type derives from IServiceBehavior. This works on the full framework, but on .Net Core an ArgumentException
is thrown with the message "Type passed in must be derived from System.Attribute or System.Attribute itself." Here is a simple repro which runs to completion on the full framework but throws on .Net Core.
using System.Reflection;
using System.ServiceModel;
using System.ServiceModel.Description;
class Program
{
static void Main(string[] args)
{
var ti = typeof(MyService).GetTypeInfo();
var attrs = ti.GetCustomAttributes(typeof(IServiceBehavior), false);
}
[ServiceContract]
public interface IMyService
{
[OperationContract]
string Hello(string hello);
}
public class MyService : IMyService
{
public string Hello(string hello) { return hello; }
}
}