Question

I have a WCF service reference (= client proxy) generated 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 invoke a WCF operation that returns the above mentioned data contract, I get the following exception:

Type 'System.DateTimeOffset' cannot be added to list of known types since another type '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 struct in System.Runtime.Serialization that is used when serializing DateTimeOffset objects. So why does it cause this exception and how can this be fixed or avoided?

Was it helpful?

Solution

In my case the issue seemed to stem from having .Net 4 installed prior to adding IIS as a feature to Windows 7.

A colleague and I fixed the issue by opening an elevated (Run As Administrator) command prompt. Then ran the following:

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

Hope this helps someone!

OTHER TIPS

I don't know why. But to solve the problem try to migrate your project to .NET Framework version 4

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top