Recently I needed to add a datacontract to a service of mine, that didn’t have a method associated. It seemed pretty straight forward, but ended up being very simple, but I could find little to no documentation about adding an additional data contract with no dependencies. Why would you want to do this? Well, I was in need for sharing the logical structure of the object down to code that would end up pushing out xml objects in the required format for my wcf service.

Seems you cannot just add a datacontract, you actually have to have some method that utilizes the datacontract for your wcf service to see it as a required dependency, and therefore include it at runtime. I went ahead and just created a simple method that would return a list of the specified type, and presto, we have a datacontract.

It seems there’s quite a few people who’ve run into a similar situation, but I couldn’t find much information regarding this in all the threads I searched, so I figured I’d share it here.

Advertisements