.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

REST WCF Serialization error

Posted By:      Posted Date: September 21, 2010    Points: 0   Category :.NET Framework
How to handle serialization error. For example, how to handle this  "There is an error in XML document (1,2)" and throw an appropriate message back to the user. I am using REST Starter Kit. I have to throw HttpBadrequest instead for InternalServer Error. Pls. help.

View Complete Post

More Related Resource Links

Serialization error in a for each loop

I have a for each loop in a 3.5 workflow. This takes a list if criteria to build a query string to call a Secure Webservive necesitating the use of a certificate. I load the certificate further up stream and pass it as a dependency property. The process returns a serialization error for the certificate. How do I avoid this error?  Thanks!

WCF REST webservice authentication error when hosted with godaddy

Hi guys, I'm currently hosting my site on a shared windows hosting box with Godaddy. I have upgraded my hosting account to .NET 3.5 and having IIS7 as well which is in integrated pipeline mode. I recently build a simple WCF web service using the REST started kit preview 2. Once i uploaded it to the server, I am getting this error"IIS specified authentication schemes 'Basic, Anonymous', but the binding only supports specification of exactly one authentication scheme. Valid authentication schemes are Digest, Negotiate, NTLM, Basic, or Anonymous. Change the IIS settings so that only a single authentication scheme is used." You can see it here:http://sawasdeethaiart.com/service.svcThe obvious fix for as i have read from various websites, is to make sure I configure my IIS to have either Basic or Anonymous specification enabled. But as i am on a shared hosting account, i dont have any access to do this. (I have checked all my options in the IIS hosting panel, but there is no option). I am also done this in my web.config<authentication mode="None"></authentication> Is there any other option I can add  to my web.config to overcome this? or is there any other fix for this? Any help will be greatly appreciated. Thanks,Mark  

WCF REST and Custom Error Handler

I have a RESTful WCF service, and I am trying to roll a custom behavior that extends the WebHttpBehavior, to provide my service a custom error handler (by implementing IErrorHandler of course). When I debug my service, the only breakpoint I hit is the getter on the BehaviorExtensionElement's BehaviorType property. None of the other methods are ever invoked; BehaviorExtensionElement.CreateBehavior(), WebHttpBehavior.AddServerErrorHandlers(), as well as nothing in my implementation of IErrorHandler. This leads me to believe that something isn't being registered with WCF. My service is defined in the app.config. When I step-through a call to one of my service's operations, I would expect that the process of throwing an exception would force my service to transfer the work to my error handler. But this is not the case... My service stops and throws me an unhandled exception, and nothing is sent to the client as a result. Am I doing something wrong? Am I not understanding this process? If someone could help me out it would be greatly appreciated!My code basically has implementations of IErrorHandler, and classes that derive WebHttpBehavior with an override on AddServerErrorHandlers(), and also BehaviorExtensionElement with an override for the property BehaviorType and method CreateBehavior(). Nothing fancy, but I have a feeling I may be missing something...This is my app.config:&

Assembly load error system.runtime.serialization

Hello ! I have a web project which i began there is some month, and compile perfectly until now. In fact, i have some compile error;   erreur 1 Could not load file or assembly 'System.Runtime.Serialization, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The module was expected to contain an assembly manifest.   on explorer :   The module was expected to contain an assembly manifest. (Exception from HRESULT: 0x80131018) Description : Une exception non gérée s'est produite au moment de l'exécution de la demande Web actuelle. Contrôlez la trace de la pile pour plus d'informations sur l'erreur et son origine dans le code. Détails de l'exception: System.BadImageFormatException: The module was expected to contain an assembly manifest. (Exception from HRESULT: 0x80131018) Erreur source: Une exception non gérée s'est produite lors de l'exécution de la demande Web actuelle. Les informations relatives à l'origine et l'emplacement de l'exception peuvent être identifiées en utilisant la trace de la pile d'exception ci-dessous. Trace de la pile: [BadImageFormatException: The module was expected to contain an assembly manifest. (Exception from HRESULT: 0x80131018)] System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBa

PUT method gives error 400 "Bad Request" in WCF REST Service Application

I am trying to learn WCF REST Services through http://blogs.msdn.com/endpoint/archive/2010/01/14/updating-state-in-wcf-webhttp-services.aspx , It's a link of Part 3 of 12 part blog series. Now I am trying the same stuff given in the part 3 with my own Entities and Entity Model instead of what is given in the blog. Here is my full project I am working on .. http://cid-9e3f62c0688824b0.skydrive.live.com/self.aspx/.Public/pronerveEPMS.zip For comparision with the code shown in the Blog I am following, you can download the zip file of the project from the same link given here at starting (At the end of the blog and before comments starts). And here is the method in Program.cs file of console project in my application that raises the exception.....        private static Role UpdateRole(HttpClient hc, Role role1)        {            Console.WriteLine("Updating Role {0} : ",     role1.RoleID);            Console.WriteLine();            string updateURI = "Roles/" + role1.RoleID.ToString();            HttpContent content = HttpContentExtensions.CreateDataContract(role1);            using (HttpResponseMessage response = hc.Put(upd

De-serialization error, The referenced element with ID 'id0' was not found in the document.

I am trying to talk to a 3rd party (java Based) SOAP web service, and get the error "The referenced element with ID 'id0' was not found in the document." when it tries to de-serialise the repsonse the repsonse is below,  and seem to be correct and complete so i am looking for suggestions on how to resolve this, if it help i ONLY need to get the CONTEXT_ID out of the response <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Header><ns1:sessionID soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" href="#id0" xmlns:ns1="http://xml.apache.org/axis/session"/></soapenv:Header><soapenv:Body><ns2:initExportDeviceResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="http://diamondip.com/netcontrol/ws/"><initExportDeviceReturn href="#id1"/></ns2:initExportDeviceResponse><multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="soapenc:long" xmlns:soapenc="-

WCF REST deployment Error: "Resource Does not exist"

I am trying to access http://localhost/TestServiceHost/TestService.svc and I am getting the following error: Error Description: 'Resource does not exist' This may be because an invalid URI or HTTP method was specified. Please see the service help page for constructing valid requests to the service. The funny thing is that http://localhost/TestServiceHost/TestService.svc/help is working fine. Not only that, all my endpoints are working fine. I am using IIS 7.5 (Win 2008 R2). Application developed using .NET 4.0.  Following is the code (extracted from my prototype) and configuration:   <ServiceContract()> Public Interface ITestSvc <OperationContract()> <Description("")> <WebInvoke(Bodystyle:=WebMessageBodyStyle.Bare, Method:="POST", UriTemplate:="GetCodes")> Function GetCodes(ByVal oReq As ReqGetCodes) As RespGetCodes End Interface Public Class TestSvc Implements ITestSvc Public Function GetCodes(ByVal oReq As ReqGetCodes) As RespGetCodes Implements ITestSvc.GetCodes Dim o As New RespGetCodes Dim lstGetCodes = New List(Of ClassGetCodes) From { New ClassGetCodes With {.App_Code = "a1", .SystemFlag = True}, New ClassGetCodes With {.App_Code = "a2", .SystemFlag = False}, New ClassGetCodes With {.App_Code = "a

Script task XML Serialization error



2008 SQL Integration Server package has the script task and in the Main method the following code is added-

Document document = new Document();

      document.Customers = new List<Customer>();
      Issuer issuer = new Issuer();
      issuer.IssuerID = "6650";
      issuer.IssuerContactFirstName = "import_testissuer_firstname";
      issuer.IssuerContactLastName = "import_testissuer_lastname";
      issuer.IssuerContactEmail = "import@testissuer.email";
      issuer.IssuerContactPhone = "6666";
      List<Customer> custs = new List<Customer>();
      Customer cust = new Customer();
      cust.custID = "6648";
      List<CustOrder> orders = new List<CustOrder>();
      CustOrder order = new CustOrder();
      order.CustOrderExpectedDelDate = &quo

2 Questions about serialization and error coding...


1. When using serialization on a controller any associated/aggregated classes returned an error that they weren't serialized. If I add serialization to these classes will they load automatically when I deserialize the controller class saving me many lines of code?

2. Slightly more complicated. I'm doing a project that requires a text editor to have error correction for a particular language like VS does for c#,VB etc. This is going to be like BlueFish editor where you select the language and it tells you if there are mistakes with the code etc. As a small project it won't have full functionality but it's the code structure and OO technique that's important. Can anyone advise me or show example of the best and most efficient way to achieve this? I'll be doing my own research but I don't want to start it and after a week find it's unreliable or unefficient. If anyone has experience in this then let me know Thanks.

Error while accessing a WCF REST service from iphone


Hi All, I have a WCF Rest service which gets a image file as a byte array[]. It works fine if the client is .net. if the client is iphone[objective c] it says the following error. The incoming message has an unexpected message format 'Raw'. The expected message formats for the operation are 'Xml', 'Json'. This can be because a WebContentTypeMapper has not been configured on the binding. See the documentation of WebContentTypeMapper for more details. The service has been hosted secure site in iis.Please help me to resolve the issue. my method is

public string ImageData(byte[] imgfile) {

 long ll = imgfile.Length; byte[] dBytes = imgfile;

 Stream imgStream = new MemoryStream(dBytes, 0, dBytes.Length);

Bitmap bmpImage = new Bitmap(imgStream);

 bmpImage.Save(@"C:\1.jpeg", System.Drawing.Imaging.ImageFormat.Jpeg); return true; }

WCF de serialization error -- finding the erring field (urgent)


Hi Folks,

Need some urgent help. I am writing a WCF client which calls a service. Now, while de serializing the response from the service, the WCF client errs out with 'De serialization error'. In the inner exception, it gives the co ordinates of the erring field (e.g.: 5, 113). This de serialization error in my case is caused because of data type mismatch between the data sent by the service, and that in the .Net wcf proxy.

My question is how do we pin point the exact field based on the co ordinates given in the inner exception, if at all we are using any http debugger like Fiddler. I am finding it very difficult to exactly pinpoint the erring field based on the inner exception.

Thanks a lot,


Odd xml serialization runtime error


What's wrong with the following code?

It throws a runtime exception complaining about missing XmlInclude attribute.

using System;
using System.Collections.Generic;
using System.Xml.Serialization;

namespace ConsoleApplication10
  class Program
   static void Main(string[] args)
     //this works fine
     //var s = new XmlSerializer(typeof(VwDeviceMetaDeclaration));
     //s.Serialize(Console.Out, new VwDeviceMetaDeclaration());

     //this doesnt
     var s = new XmlSerializer(typeof(VwMetaDeclaration));
     s.Serialize(Console.Out, new VwMetaDeclaration());

  [XmlRoot(ElementName = "meta", Namespace = "http://schemas.cside.pt/METADATA")]

IsapiModule Error 500 Issue


I am about exhausted trying to figure out this error:

HTTP Error 500.0 - Internal Server Error

Description: The page cannot be displayed because an internal server error has occurred.

Error Code: 0x8007007b

Notification: ExecuteRequestHandler

Module: IsapiModule

Requested URL: http://localhost:80/ReportServer

Physical Path: c:\Program Files\Microsoft SQL Server\MSSQL.2\Reporting Services\ReportServer

When I enable Failed Request Tracing Rules and view the log output I am supposing that the actual problem is in the 2nd call where there are 2 backslashes before the actual filename in the specified path:


CALL_ISAPI_EXTENSION DllName="C:\Windows\Microsoft.NET\Framework\v2.0.50727\\aspnet_isapi.dll"


Handling 404 page not found with Error page



      How do i handle 404 page not found?

Inserting personal error message in ValidationSummary



I am creating a web form that requires a lot of validation. I use many of the validation control in asp.net already like RequiredFieldValidator and CompareValidator. 

My Problem: after my custom validation for the value entered return an error message, and I pressed enter key when the field is empty, my custom error message is overlapped by my ValidationSummary. 

Setting my custom error to visible = false on button click also does not seem to work as it requires for me to enter the value first.

This made me think, is there a way to insert my custom validation inside the ValidationSummary as an error message like for other validation control?

Thanks in advance

Sys.Net.WebServiceFailedException: The server method '' failed with the following error:



Let's say we have 2 time consuming functions, aaa and aaa1 inside a aspx page.

        public static string aaa(int i)
            return i.ToString();

        public static string aaa1(int i)
            return i.ToString();



        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
        <span id="displayspan"></span>
        <br />
        <input type="button" value=

Jscript error: Object does not support property or method


 Hi, i have little knowledge on javascript but i need to use this code get from somewhere for a jquery to work.

I face this "Jscript runtime error: Object does not support property or method" whenever im trying to run this page.

In my experience, im get this error msg 9 out of 10 times i use javascript in my system.

Im using Microsoft Visual web developer 2008, i wonder if this is related to my problem, i not sure there is anything i need to add as reference or update anything.

But anyway, in short, i just couldn't use javascript code when using this development tool because of this sort of error.

Anyway, it happen that last time i tried use the same type of jquery code in another project and it seems to work well without an error.

But now when im try to use it again in this recent project i created, it come out with this error and i have no idea how to solve it even look through google and this forum.

It doesn't really seems like its the code problem itself although im not sure, because any javascript code just couldn't work.

So below is my code that i need to use.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" ></script>
<script type="text/javascript" src=&quo
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend