C# - WCF - Serializing external classes

I was receiving a "cannot serialize type..." error while attempting to serialize a BindingList. My initial thought was that the collection was the problem. I bypassed the collection and attempted to return a single instance of the class...same error. The classes are contained in a seperate project (but in the same solution); my next move was to copy and paste the class from the external project into the WCF project. With no other changes, the object now serializes.

Is this a namespace or persmissions issue? I can't rearchitect the solution at this point. What would prevent the class from seralizing in another project with the same code? Thanks in advance.


Often when we get this error there is a sub class that does not have the Serializable or DataContract / DataMember attribute.

What is the class that you are using as T? Is that class marked as serializable?


For the error in the comment see "An attempt was made to load a program with an incorrect format" even when the platforms are the same

The fix for this was to simply recreate the WCF solution and add the class library projects to it. I have no idea what the problem was. Maybe bad meta information or something.

Category:asp.net Time:2011-08-19 Views:1

Related post

  • Why is WCF serializing a Enum as a string? 2010-07-06

    Code on the server <DataContract(Namespace:="http://schema.aam.us.com/2010/6", Name:="TradeStatus")> Public Enum TradeStatus NewOrder = 100 SendToProvider = 101 ProviderSubmitted = 102 ProviderAccepted = 103 ExecutionPending = 104 Executed = 10

  • WCF serializing error - 'System.Net.Mail.MailAddress' cannot be serialized 2010-07-21

    Please help me with this WCF error....How do I handle these builtin classes for WCF? Type 'System.Net.Mail.MailAddress' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serial

  • WCF - Serializing derived classes where base class is base containing fields that are of type 2010-12-20

    I have domain objects defined using the following pattern... public abstract class BaseObject<IdT> { private IdT id = default(IdT); private DateTime dtCreatedOn; public IdT ID { get { return id; } set { id = value; } } public DateTime CreatedOn

  • WCF serializing objects with inheritance 2011-04-12

    Here's what I am trying to do. I have a WCF restful service, and I need to serialize multiple objects that inherit from the same class. There is nothing in any of the base classes that needs to be serialized. Here is a minimal demo that shows what I

  • Howto: WCF service external to solution (not domain!) with AutoCompleteExtender 2012-01-31

    I've coded a WCF service that is external to the solution I wish to use it in. I'm doing this so that I can have one service that's reusable across many solutions. We've already duplicated this service many times as an asmx integral to the solution a

  • Close NHibernate session after WCF serialized return object 2011-01-31

    I have an IIS hosted WCF service with single-call behavior. I use Fluent NH for data access and faced the following issue. I cannot close/dispose NH session inside of method body because when serialization comes to the game it cannot access lazy load

  • How to start a WCF service outside Visual Studio? 2009-02-17

    I just created a WCF service with this MSDN tutorial. from within Visual studio I can CTRL-F5 the service so it is running then I can start my Console Application Client and consume the service no problem Now I want to start my service OUTSIDE visual

  • WCF. IList is deserialized as array. How to make it be any writable list (ArrayList)? 2011-12-06

    I have a client-server application, parts of which "talk" to each other through WCF (netTcp binding). I have my DataContract, which has 1 field of a 3rd party class: [Serializable] public class MyResult{ public ThirdPartyResult Result {get;set;} /* o

  • Want to access a SOAP service and show data in external list 2012-11-25

    Hi, I was able to acccess a WCF Service via External Content type successfully. Now i want to access a SOAP Service and show data in external list in Sharepoint 2010. I am able to create a Datasource successfully with the SOAP service but how to show

  • ASP.NET forgets dlls in bin directory 2010-03-13

    We have a plugin system on a WCF service that checks libraries placed in the bin folder for certain assembly level attributes and loads them. This allows customization of certain service calls based on which client is making the call. This works grea

  • Anyone have experience with ServiceStack or other .Net services framework? 2010-06-11

    I'm looking for at using ServiceStack for the services part of a web application instead of rolling my own. Anyone have any experience using it? Any C#/.Net alternatives I should consider? --------------Solutions------------- I'm planning to use Serv

  • In C#, why is "int" an alias for System.Int32? 2011-12-24

    Since C# supports Int8, Int16, Int32 and Int64, why did the designers of the language choose to define int as an alias for Int32 instead of allowing it to vary depending on what the native architecture considers to be a word? I have not had any speci

  • .NET base type cannot be serialized by WCF 2008-10-30

    I'm writing a WCF service and want to expose some custom configuration elements (e.g. Custom ConfigurationSection and ConnectionStringSettings) so that I can modify the service's configuration. One of my custom configuration elements inherits from Sy

  • Converting serialized WCF objects back to native objects 2008-12-30

    I miss the .Net remoting days when I could just send an object over the wire and it would work on both sides of the middle layer without much work. Here's why: I've been given an assignment. I'm building a Logic/Data Abstraction layer (stupid PCI Com

  • WCF Recommend approaches for serializing multiple objects 2009-02-12

    I am attempting to optimise around a possible bottleneck. I have a server application that is serving objects from a database to applications remotely, who can work with 1 - n objects of 1 - n different types (where n can be a relatively high number)

  • 404 BadRequest exposing WCF service through external IP using IIS host headers 2009-02-16

    We host a WCF webservice on Windows Server 2003. This server only has 2 internal IP's. We want to expose the service externally. This is done through the firewall that maps an external IP to the service. So, I would need to modify the service to disp

  • Any solution or workaround to serializing SQLParameter in WCF? 2009-04-01

    I originally defined in my MessageContract a collection of SQLParameters in order to create a simple stored procedure execution through a WCF service. Apparently, SQLParameter is not serializable, so I need some advice on how to proceed here. Is it p

  • Serializing linq entities with WCF 2009-04-16

    I am serialzing a linq object through WCF. The dbml is setup for unidirectional serialization. My objects are pretty simple: Budget has a collection of BudgetLineItems. Each BudgetLineItem has an ItemCateogry. Budget/BudgetLineItems are serialized fi

  • Is it possible to communicate with an external system over TCP/IP using WCF? 2009-04-29

    We are building a system that interacts with an external system over TCP/IP using the FIX Protocol. I've used WCF to communicate from client to server, where I had control over both client and server, but never to an external TCP/IP based system. Is

Copyright (C) pcaskme.com, All Rights Reserved.

processed in 0.574 (s). 13 q(s)