How to configure known types dynamically

12 03 2011

Using WCF you may need to configure known types dynamically. Doing it is quite simple, you have to add your types (The types that you want to register dynamically) into the KnownTypes collection of the OperationDescription instance of your WCF service.

foreach (var operation in client.Endpoint.Contract.Operations)
{
  //_typeCollection is your known types collection that you want to register.
  foreach (Type type in _typeCollection)
  {
    operation.KnownTypes.Add(type);
    operation.KnownTypes.Add(type.MakeArrayType());
  }
}
Advertisements

Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: