I have a message inspector in which I am trying to get the type of contract for the current endpoint. I want to reflect on the type but GetType returns null.
var contractType = Type.GetType(OperationContext.Current.EndpointDispatcher.ContractName);
if (contractType != null)
{
foreach (var member in contractType.GetMembers())
{
//do stuff
}
}
I am guessing because OperationContext.Current.EndpointDispatcher.ContractName holds the name of the interface instead of the fully qualified type name it can’t get the type. My config has the fully qualified type name so I’m not sure why .NET is doing that. Is there another way I can get it?
You will find the correct type via:
See MSDN:
DispatchRuntime.Type – Gets or sets the contract type