DateTimeOffsetAdapter prevents serialization of WCF DateTimeOffset objects

I have a WCF service link (= client proxy) created by Visual Studio 2008 (.net 3.5 sp1). The generated code contains a data contract with DateTimeOffset properties, so naturally, VS decorated it with KnowTypeAttribute (System.DateTimeOffset).

Whenever I call a WCF operation that returns the above contract, I get the following exception:

The type 'System.DateTimeOffset' cannot be added to the list of known types because another type is' System.Runtime.Serialization.DateTimeOffsetAdapter 'with the same data contract name' http://schemas.datacontract.org/2004/07/System: DateTimeOffset 'is already present

I understand that DateTimeOffsetAdapter is a structure in System.Runtime.Serialization that is used when serializing DateTimeOffset objects. So why does this raise this exception and how can this be eliminated or avoided?

+6
serialization datetimeoffset wcf
source share
2 answers

In my case, the problem seems to be related to what .Net 4 installed earlier to add IIS as a function for Windows 7.

A colleague and I fixed the problem by opening a command prompt with an elevated (Run As Administrator). Then the following was done:

cd C:\Windows\Microsoft.NET\Framework64\v4.0.30319 aspnet_regiis.exe -i 

Hope this helps someone!

0
source share

I do not know why. But to solve the problem, try porting your project to the .NET Framework version 4

0
source share

All Articles