Today I spent couple of hours figuring out why I suddenly got an error "Referenced type 'x`1, ... with data contract name 'xIF_Ph6aZR' in namespace 'x cannot be used since it does not match imported DataContract. Need to exclude this type from referenced types."
It was working and what I did just little bit of re-factoring. What I found is that there is a combination of conditions that does not work, while every one of them works separately:
- Generic class is used as DataContract.
- This class has nullable DataMember property
- You want to reference your class in your client instead of creating in through wsdl.
[DataContract]and then you use it like this:
public class DummnyContract<T> where T: IBusinessObject
{
[DataMember]
public DateTime? LastModified{get;set;}
}
[ServiceContract]
public interface IService
{
[OperationContract]
DummyContract<int> Get(int id);
}
This just does not work when you reference your assembly with declaration of this class. You can have it without class being generic. Or, you can have generic without nullable property. But not together.
0 comments:
Post a Comment