Bug 7701 - It lies in the app.config at dataContractSerializer, "Cannot cast from source type to destination type."
Summary: It lies in the app.config at dataContractSerializer, "Cannot cast from source...
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: WCF assemblies (show other bugs)
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2012-10-06 00:08 UTC by Meanbunny
Modified: 2012-10-11 14:13 UTC (History)
2 users (show)

See Also:
Is this bug a regression?: ---
Last known good build:

The project in question. (31.22 KB, application/x-zip-compressed)
2012-10-06 00:08 UTC, Meanbunny

Description Meanbunny 2012-10-06 00:08:22 UTC
Created attachment 2697 [details]
The project in question.

I was trying to create a simple WCF service for testing on my Windows 7 machine in MonoDevelop. Once I got it up and running I decided to copy the same project onto my Ubuntu machine and run it. When I ran my WCF server, and got the following exception, "Cannot cast from source type to destination type.". After looking online for a solution I realized it was a generic error so I started digging around for different solutions. 

This service uses an app.config file for configuring its service endpoints that I had copied from another project of mine and modified for this one. I was able to finally figure out that it was related to the behaviorConfiguration of the service in the config, only by deduction.

<behavior name="serviceBehavior" >
  <dataContractSerializer maxItemsInObjectGraph="2147483647" /> <!--The problem lies here in this line-->
  <serviceDebug includeExceptionDetailInFaults="true" />

In my previous project I had to allocate for the maximum amount of items to be sent over the wire. Removing that line allowed my simple app to run, but just wanted to point it out for a bug report if it is one.

Oddly enough it worked on my Windows machine but not Ubuntu 12.04.
Comment 1 Zoltan Varga 2012-10-11 14:13:32 UTC
-> wcf.

Note You need to log in before you can comment on or make changes to this bug.