datacontract

Is there a way to export an XSD schema from a DataContract

I'm using DataContractSerializer to serialize/deserialize my classes to/from XML. Everything works fine, but at some point I'd like to establish a standard schema for the format of these XML files independent of the actual code. That way if something breaks in the serialization process I can always go back and check what the standard sch...

Any XmlSerialization Limitations in WCF (as opposed to DataContract)?

Is there anything I might regret later, i.e. any major limitations if we choose XmlSerialization instead of DataContract? Until now, we have embraced the schema first contract design. For example, if we want to parameter inspection, security enhancements, etc... will locking in now with XmlSerialization be a problem when we try to add...

Datacontracts property getter running twice

I have a set of data contracts that act as wrappers to base classes that we wish to expose. A quick example is: [DataMember] public List<decimal> Points { get { return sourceObject.ListPoints(); } private set{} } We have some other properties that we have to massage the data first (we are converting object gr...

Generate Entity Data Model from Data Contract

I would like to find a fast way to convert a Data Contract to a Entity Data Model. Consider the following Data Contract: [DataContract] class PigeonHouse { [DataMember] public string housename; [DataMember] public List<Pigeon> pigeons; } [DataContract] class Pigeon { [DataMember] public string name; [DataMe...

Silverlight WCF serialization DataContract(IsReference=true) problem

Hi, I'm have a Silverlight 3 UI that access WCF services which in turn access respositories that use NHibernate. To overcome some NHibernate lazy loading issues with WCF I'm using my own DataContract surrogate as described here: http://timvasil.com/blog14/post/2008/02/WCF-serialization-with-NHibernate.aspx. In here I'm setting preserveO...

Why are we getting a WCF "Framing error" on some machines but not others

We have just found we are getting “framing errors” (as reported by the WCF logs) when running our system on some customer test machine. It all works ok on our development machines. We have an abstract base class, with KnownType attributes for all its sub classes. One of it’s subclass is missing it’s DataContract attribute. Howeve...

Enums, DataContracts and WCF question

I am new to WCF and have a simple question... My DataContract class returns an Enum type to the consumer from one of it's exposed methods. The consumer is able to see the enum type, and instantiate variables of that typel. However, I have not provided a [DataContract] nor [EnumMember]s for the enum in the service. My question is, wh...

DataContract Known Types - passing array

Im having problems when passing an generic List, trough a WCF operation. In this case, there is a List of int. The example 4 is described here in MSDN. Note that in MSDN sample, is described: // This will serialize and deserialize successfully because the generic List is equivalent to int[], which was added to known types. Above, ...

Can I find out what WCF methods are supported on the endpoint before calling it?

I have a versioning issue with a WCF service contract in which one of the many endpoints which are called for the operation is missing one method from the contract. My question is, how can I make sure the command is available on the client before attempting to call it? I tried: foreach (var od in proxy.Endpoint.Contract.Operations) ...

WCF DataContractSerializer Behavior

I'm seeing some unusual behavior when using the DataContractSerializer. I have defined a message contract like so: namespace MyNamespace.DataContracts { [MessageContract(WrapperName = "order", WrapperNamespace = @"http://example.com/v1/order")] public class MyOrder { [MessageBodyMember(Namespace = @"http://example.com/v1/order", Ord...

C# Inheriting DataContract Derived Types

I've given a fair read through msdn:datacontracts and I cannot find a out why the following does not work. So what is wrong here? Why isn't ExtendedCanadianAddress recognized by the datacontract serializer? Type 'XYZ.ExtendedCanadianAddress' with data contract name 'CanadianAddress:http://tempuri.org/Common/Types' is not expected. Add ...

Is there a limit to the number of DataContracts that can be used by a WCF Service?

Using WCF3.5SP1, VS2008. Building a WCF service that exposes about 10 service methods. We have defined about 40 [DataContract] types that are used by the service. We now experience that adding an additional [DataContract] type to the project (in the same namespace as the other existing types) does not get properly exposed. The new typ...

confused about how to use JSON in C#

The answer to just about every single question about using C# with json seems to be "use JSON.NET" but that's not the answer I'm looking for. the reason I say that is, from everything I've been able to read in the documentation, JSON.NET is basically just a better performing version of the DataContractSerializer built into the .net fram...

WCF - DataContract that inherits from an interface

I have a datacontract as part of my WCF Interface that inherits from IIdentity: [DataContract] public class AuthenticationIdentity : IIdentity { //implements IIdentity... } The service returns my AuthenticationIdentity objects just fine. However, when I try and do the obvious cast on the client: AuthenticationIdentity aId = c...

In WCF, is it better to have multiple operation contracts or to have only one operation with polymorphic data contract?

I was wondering if it was better in WCF to use multiple operation contracts or to have only one operation contract with a polymorphic data contract. Let me give you a small example : [OperationContract] action1Answer action1(action1data a); [OperationContract] action2Answer action2(action2data a); or [OperationContract] actionAnswe...

Asp.Net MVC 2: Any way to share data contracts with client side javascript?

If you have the following: Asp.Net MVC 2 project having object classes that define view models. Serialize these models to the web browser client using JSON. Client adds information to the objects, like an Order Line on an Invoice. Client sends back the object to the server for processing. Is there any way to share with the client a d...

Clone LINQ To SQL object Extension Method throws object dispose exception....

Hello all, I have this extension method for cloning my LINQ To SQL objects: public static T CloneObjectGraph<T>(this T obj) where T : class { var serializer = new DataContractSerializer(typeof(T), null, int.MaxValue, false, true, null); using (var ms = new System.IO.MemoryStream()) { serializer.WriteObject(ms, obj)...

Using WCF with abstract classes

How do I define DataContract for abstract classes in WCF? I have a class "Person" which I communicate successfully using WCF. Now I add a new class "Foo" referenced from Person. All still good. But when I make Foo abstract and define a sub class instead it fails. It fails on the server side with a CommunicationException, but that doesn...

Designing WCF Contracts (Operation / Data)

I am currently looking to design some WCF services and wanted to get the community's opinion on the best way to handle operation / data contracts. I have 2 basic operation contracts, the first creates a quote and the second adds an item to a quote (and calculates totals behind the scene). The first takes in customer information and sto...

Serializing Delegates in WCF Using a Surrogate?

I have an idea, but I need help implementing it. WCF does not support delegates in its contracts. Instead it has a cumbersome callback contracts mechanism, and I'm looking for a way to overcome this limitation. I thought about using a IDataContractSurrogate to replace each delegate in the contract with a token that will be serialized t...