How to retrieve unknown types of contract in client when the the WCF server implements ServiceKnownType?
Types that pose problems, are not returned or used as a parameter. I integrated GetKnowTypes() on my server like this: WCF Problem Sending Object To Client
[ServiceKnownType("GetKnownTypes", typeof(KnownTypesProvider))]
public interface ITestCallback
{
//What I liked to do:
[OperationContract(IsOneWay = true)]
void TestPropertyChanged<T>(string propertyName, Type propertyType, T propertyValue);
//What I think is required:
[OperationContract(IsOneWay = true)]
void TestSerializedPropertyChanged(string propertyName, string propertyType, string serializedPropertyValue);
}
Apparently we can not use Type T. So I serialized my property, and I would like to deserialize in my client, but for that I need the original Type.
I would like to get Types with something like this in the client:
/// <summary>
/// Get custom types from server
/// </summary>
private Type GetPropertyType(string typeName)
{
try
{
var types = KnownTypesProvider.GetKnownTypes(); //ERROR : The name 'KnownTypesProvider' does not exist in current context
foreach (var knownType in types)
{
if (knownType != null && knownType.FullName == typeName)
return knownType;
}
}
catch (Exception)
{
}
}
Is it possible ? and How ?