The Life and Times of a Dev

Yes, we're really that weird
posts - 179, comments - 302, trackbacks - 106

My Links

News

Twitter









Tag Cloud

Archives

Post Categories

Play

Work

Known Types

We're using Nettiers to generate our DAL and have the need to create a WCF layer for it.  So we set up the WCF layer in a codesmith template and immediately ran into a problem, we had thousands of methods in the service contract, and the service took over a minute to initialize.  Yuck.

We could have separated out the service contracts into a bunch of different contracts, but that would have been nasty--we would have had over 100 some odd different services to put in the config file.

So the next option was to make a method that allowed us to pass in the provider, method name, and parameters to the method and then call that method on the SQLClient provider using reflection.

I was able to get that wired up and then got the following message in the trace of the server call (note that I removed class names):

There was an error while trying to serialize parameter "blah". The InnerException message was 'Type 'TList`1[[Entity, dll, Version=1.0.149.0, Culture=neutral, PublicKeyToken=null]]' with data contract name 'ArrayOfEntity:http://schemas.datacontract.org/2004/07/' is not expected. Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.'.  Please see InnerException for more details.

After some searching, I found an article about adding known types.  I'll probably opt for the static version.  We'll see how it goes.

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Print | posted on Thursday, July 12, 2007 11:18 AM |

Feedback

Gravatar

# re: Known Types

Did you ever figure this out? I am in the same boat with respect to having a ton of specialized Request/Response messages. I did come up with a solution by creating Message Base classes and adding the specialized messages with the KnownTypes attribute. The drawback is that casting has to occur on both ends of the wire.

Let me know how it worked out for you.
-
Seth
8/10/2009 11:02 AM | seth arakelian
Gravatar

# re: Known Types

We ended up bailing on Nettiers, so the problem largely went away. We also ended up adding known types in the serializer initialization.

Honestly, this has been so long ago (over 2 years) that I don't even remember the full solution!
8/11/2009 12:52 PM | Robert
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 
 

Powered by: