.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

Help!!! WCF:: The formatter threw an exception while trying to deserialize the message

Posted By:      Posted Date: September 09, 2010    Points: 0   Category :ASP.Net
I have[ServiceContract]    public interface IBusiness    {        [OperationContract]        [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]        bool UpdateLanguage(int languageId, string name, string code);    }public class Business:IBusiness    {        public bool UpdateLanguage(int languageId, string name, string code)        {           //update to database        }    }Add client:$.ajax({ type: "POST", url: "/Services/Business.svc/UpdateLanguage", data: "{'languageId':'" + languageId + "', " + "'name':'" + name + "'," + "'code':'" + code + "'}", contentType: "application/json; charset=utf-8", dataType: "json", processdata: true, success: function (response) { //rebind data here!

View Complete Post

More Related Resource Links

The formatter threw an exception while trying to deserialize the message

Hi I got this error when programming in C# 2008 The formatter threw an exception when trying to deserialize the message: Error while trying to deserialize parameter http://tempuri.org/:GetListSitesResponse. The InnerException message was' Error on line 1, position 314. The item 'http://tempuri.org/:anyType' contains data data contract 'http://tempuri.org/:Site'. The deserializer has no knowledge of any type that is assigned to this contract. Add the type corresponding to 'Site' to the list of known types (eg, using the attribute KnownTypeAttribute or adding it to the list of known types passed to DataContractSerializer). '. See InnerException for more information. This happen in my button_click event (this is a project on C# 2008 express windows form application) private void button1_Click(object sender, EventArgs e)         {             SiteDevelopmentReference.Service1SoapClient sd = new SiteDevelopmentReference.Service1SoapClient();             listBox1.Items.AddRange(sd.GetListSites().ToArray());                            } I have a service reference from another project

UpdateListItems & "The formatter threw an exception while trying to deserialize the message"


I'm trying to update a column in a SharePoint List with the following code. The column is updated, but an error is thrown trying to deserialize the SOAP response message. I've not been able to trap the raw SOAP response message to see what's being passed back...so I don't know what else to do to debug this issue.

        static public void updateMigrationFlag(string targetList, string projectID)


            string sQuery = @"<Batch OnError='Continue' ListVersion='1' ViewName=''>"

                            + @"<Method ID='1' Cmd='Update'>"

                            + @"<Field Name='ID'>" + projectID + "</Field>"

                            + @"<Field Name='hMigrationStatus'>True</Field>"

                            + @"</Method>"


Cash Drawer - Method Open threw an exception - Windows Service

Hi All, I'm getting the following exception while calling Open method of Cash Drawer object. Method Open threw an exception.  Could not read the device name key's default value, or could not convert the Programmatic ID it holds into a valid Class ID. Code:   class Class1 { CashDrawer _uniCashDrawer1 = null; DeviceInfo cashDrawerDevice1 = null; PosExplorer posExplorer = new Microsoft.PointOfService.PosExplorer();   public void ClaimCashDrawer() { cashDrawerDevice1 = posExplorer.GetDevice("CashDrawer", "testDrawer"); if (cashDrawerDevice1 != null) { _uniCashDrawer1 = posExplorer.CreateInstance(cashDrawerDevice1) as CashDrawer; if (_uniCashDrawer1 != null) { _uniCashDrawer1.StatusUpdateEvent += new StatusUpdateEventHandler(UniCashDrawer1_StatusUpdateEvent); _uniCashDrawer1.Open(); _uniCashDrawer1.Claim(0); _uniCashDrawer1.DeviceEnabled = true; } } } }   Tha above code works fine if you put the code in WindowsApplication in all POS systems. The same is working if you put the code in Windows Service in all other POS systems. The same is not working if you put the code in Windows Service in Aures Galeo POS systems.  Thanks in advance. Ramakrishnan S

The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception.

 Hi all,When i run my project on my own computer, it works fine. But when i deploy it to server, it gives me this error. I can run my other dts and sp, but i get this error on this.. The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception. I googled it but could not find a solution. How can i solve this problem? 

the type initializer for 'system.runtime.remoting.identity' threw an exception.

HI, I am trying to implement kerberos delegation in Active Directory enviroment with windows 2003 servers SP2. I have Client, ProxyServer and RemoteServer application that are developed on .Net framework v3.5 using .Net Remoting "System.Runtime.Remoting". I am not using Microsoft.Samples.Security.SSPI &  Microsoft.Samples.Runtime.Remoting.Security directly. my code is based on "http://blogs.msdn.com/dotnetremoting/archive/2006/07/06/662599.aspx" Only change that I have done is put impersonate="true" in channel configuration of ProxyServer and RemoteServer, and of course changed the UPN and Port and IP address. The Client's credentials are successfully impersonated by ProxyServer, I can access the text file on ProxyServer on behalf of client. But when from ProxyServer I try to execute the method on RemoteServer it throws "the type initializer for 'system.runtime.remoting.identity' threw an exception." After looking at blog http://www.secnewsgroups.net/group/microsoft.public.dotnet.security/topic8251.aspx I did required changing under Local Security Settings -> Local Policies -> User Rights Assignments -> impersonate a client after authentication and Create Global Objects. I have added three domain user names in three machine under whose credentials corrosponding application is running. When i run three applications on their

Throwinfg Exception from a faulted Message.

Hi I havetransparent proxy that recieves a message from the service. I have to test what happens when the service throws any exception. When I generate the proxy from the "Add Service Reference" from visual studio, it works ok. If I throw a InvalidOperationException on the service it reaches the client with the traditional FaultException. But with my manyally created proxy, it only recieves the faulted messate ( the IsFault attribute is true ) but it does not throw the exception. Here are the exmamples: Host: Contract:   [ServiceContract(Namespace = "http://my.namespace.com")] public interface ICalculadora { [OperationContract] int LancaException(string codigo); }   Service:   public class Service : ICalculadora { public int LancaException(string codigo) { if (codigo == "exception") { throw new InvalidOperationException("Operação ilegal", new DivideByZeroException("Divisão por zero")); } else if (codigo == "numero") { return 32; } else if (codigo == "fault") { InvalidOperationException invEx = new InvalidOperationException("Operacao inválida dentro da faulta"); //throw new FaultException<InvalidOperation

ws-addressing 'Action' required message part not signed exception

I have a WCF client calling a Java-based service. The service vendor is supporting WCF clients. The WCF client binding uses authenticationMode="MutualCertificate", messageVersion="Soap11WSAddressing10" and the message is signed and encrypted (SignBeforeEncrypt). WCF, in this case, is automatically signing all the ws-addressing ( <Action>, <MessageID> and <To> ) headers. The message gets to the service and comes back with what appears to be valid encrypted data in the response BUT the client is throwing a "The 'Action', 'http://www.w3.org/2005/08/addressing' required message part was not signed" exception (mscorlib). Questions: Is there a way to NOT sign the ws-addressing headers in the request message while still using both signing and encryption (X.509 certs)? If the client DOES sign the ws-addressing headers in the request, is there a way to configure WCF to accept UNsigned ws-addressing headers in the response? If the answer is NO on both questions, I guess I will have to ask the service vendor to sign the ws-addressing headers in the response. Thanks.

'schema.AllCategories' threw an exception of type 'System.UnauthorizedAccessException

We're porting a solution from 2007 to 2010 and we're having trouble accessing the CrawledProperties property from the Schema object. Other properties from the Schema object however are accessible (e.g. AllManagedProperties). It does not matter whether we use the obsolete SearchContext to create the Schema object, or the new SearchServiceApplication (Example code from Steve Curran here: http://social.technet.microsoft.com/Forums/en-US/sharepoint2010programming/thread/2550e6e8-34a6-4012-969f-9657dc526d74) Now what's interesting is that the SAME user (Farm administrator) can access the AllCategories using a Windows Forms application, but when using a SharePoint solution (Codebehind on an application page) it doesn't work. We have double-checked that the executing user is the same. The same user can also browse the CrawledProperties using the Central Admin UI. We're experiencing this on several server installations, one of which is the "Standalone" installation of Search Server Express 2010, whereas the same user was used to perform the installation. I'd appreciate any ideas you might have.

WCF Exception "Message security verification failed" only with header!

Hi, I've got a WCF service doing Username authentication. I authenticate with AD and authorize using AzMan on AD. I'm hosting the service in IIS 6 and its running in an app pool that runs in a domain account that has read rights on the AD. I have a custom header that goes both ways. Everything works well until I assign the custom header to return. If I never assign the custom header to return everything is ok but if I do assign the custom header to return I get the error:- Message security verification failed.Duplicate attribute found. Both 'u:Id' and 'u:Id' are from the namespace 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'. Line 1, position 520. I've got service level message tracing and I can see the secure conversation stuff happening and the messages going across the interface.   If anyone has any ideas I'd be most appreciative.   Thanks,   Andy

ASP.net UPS void wsdl error message 'exception has been raised as a result of client data'


exception has been raised as a result of client data. at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) at System.Web.Services.Protocols.SoapHttpClientProtocol

Void shipment erro message; I can't determine how to resolve error.  at ***

The following is the code for ups void shipment wsdl...

protected void wsdlRate()


RateWSs.RateRequest rateReq = new RateRequest();RateWSs.UPSSecurity rateSecurity = new RateWSs.UPSSecurity(); RateWSs.UPSSecurityServiceAccessToken rateToken = new RateWSs.UPSSecurityServiceAccessToken

User Control Web Part - The type initializer for 'IBM.Data.DB2.DB2Connection' threw an exception.



I need help, in our SharePoint 2007 project we have created Web Part using VS 2005 & .Net 2.0, User Control. In the user control for one of the drop down list box databinding method we are using data from IBM DB2. It works fine on our local machine, but after Web Part deployment if i open the page then the Drop Down List is empty. I checked the log in the event viewer. I found the following error message in the vent viewer -

The type initializer for 'IBM.Data.DB2.DB2Connection' threw an exception.


Detail Error Message -

An unhandled exception occurred and the process was terminated.

Application ID: /LM/W3SVC/2076212728/Root

Process ID: 26880

Exception: System.TypeInitializationException

Message: The type initializer for 'IBM.Data.DB2.DB2Connection' threw an exception.

StackTrace: at IBM.Data.DB2.DB2Connection.Finalize()

InnerException: System.InvalidOperationException

Message: SQL1159 Initialization error with DB2 .NET Data Provider, reason code 7, tokens 9.1.1.DEF.2, SOFTWARE\IBM\DB2\InstalledCopies

StackTrace: at IBM.Data.DB2.y.f.a()

at IBM.Data.DB2.DB2ConnPool.g()

at IBM.Data.DB2.DB2ConnPool..ctor()

at IBM.Data.DB2.DB2Connection..cctor()

For more information, see Help and Support Center at h

Error 1259 The type initializer for 'System.Web.Compilation.CompilationLock' threw an exception.


In my asp.net application i  have getting an error

Error 1259 The type initializer for 'System.Web.Compilation.CompilationLock' threw an exception.  
 How to solve this one

I configured this application in iis.

As per the many forum result . i changed the framworkwortion in asp.net  tab of iis proprty.

So kindly give a good solution for it



@ Page AutoEventWireup="false" CodeFile="IDNotification.aspx.vb" Inherits="IDNotification" Language

throw exception message giving internal server error on live site


using vb.net/asp.net 2005

when a user enters a bad email I am doing a check on this and throwing an exception message as follows, this works fine on the test site but for some reason the same code on the live site gives a "internal server error" (http code 500).  The code below:

            If isThisEmailValid(strEmailThatTheUserEntered) Then
		'do something


                Throw New Exception("You entered a bad email address.")

            End If

not certain why this is happening, I assume that it's some server or config difference between the test and live sites.  has anyone seen this before?  For a quick fix i'm registering javascript alert and showing the same text so it works but I would like to figure out why the code above is not working.

as always, thanks for your feedback


problems when sending mail from mail program - receive exception Message MSCORLIB


When sending out email through Live mailer pro I get now the following message for each email that I want to send:


Error Message

String was not recognized as a valid DateTime.


Stack Trace

   at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
   at System.DateTime.Parse(String s, IFormatProvider provider)
   at System.Convert.ToDateTime(String value)
   at Mailer.TrackProxy.get_IsTrackOK()


Can someone tell me what I have to do to solve this problem?

I use windows server 2k



MSMQ system.messaging.message.body unauthorizedaccessexception: Access is denied (exception fro HRRE



I am facing this error long back.. Please help me in this regards...

I have my .Net 2.0 Windows service to read the Priavate non transactions message queues and process into Sql Server 2005 database.....

I have used threading concept too.. i have multiple queues to be read on regular basis...

Getting below error exactly when reading the message body

system.messaging.message mInput ;

timespan tsInput = 1000;

mInput = mqInput.Receive(tsInput);

      ActiveXMessageFormatter axFormatter= new ActiveXMessageFormatter();
      pubqloader.DMPMessage DMPmsg = new PubQLoader.DMPMessage();
      object temp = new Object();
      temp = mInput.Body; --- here getting the error 

UnauthorizedAccessException Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))   

Stack Trace1: when mInput.Body is used

System.Messaging.Interop.NativeMethods.OleLoadFromStream(IStream stream, Guid& iid)
   at System.Messaging.ActiveXMessageFormatter.Read(Message message)
   at System.Messaging.Message.get_Body()

Error warming up the worker process. - Starting worker process threw - Inner Exception: System.Runti


Can anybody guide me how to resolve this on my production server,



Error warming up the worker process. - Starting worker process threw - Inner Exception: System.Runtime.Remoting.RemotingException: 4 arguments were passed to 'Microsoft.SharePoint.UserCode.ISPUserCodeWorkerProcessProxy::Initialize'. 3 arguments were expected by this method.    Server stack trace:      at System.Runtime.Remoting.Messaging.Message.CoerceArgs(MethodBase mb, Object[] args, ParameterInfo[] pi)     at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)    Exception rethrown at [0]:      at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)     at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)     at Microsoft.SharePoint.UserCode.ISPUserCodeWorkerProcessProxy.Initialize(Int32 appDomainCount, Boolean alwaysRecycleAppDomains, Byte[] salt, Boolean logRequests)     at Microsoft.SharePoint.UserCode.SPUserCodeWorkerProcess.InitializeWorkerProcess(ISPUserCodeWorkerProcessProxy workerProcessProxy, Boolean alwaysRecycleAppDomains, Byte[] saltBytes, Boolean logRequests)     at Microsoft.SharePoint.UserCode.

Exception message: The SiteMapProvider 'SPAdministrationQuickLaunchProvider' cannot be found.


Help, how do I troubleshoot this issue that occurs when I try to go to Central Administration?


Exception information:
Exception type: HttpException
Exception message: The SiteMapProvider 'SPAdministrationQuickLaunchProvider' cannot be found.


Request information:

Request URL: http://sfvtestdev02:9810/_admin/sssvc/ManageSSSvcApplication.aspx?AppId=952b9f2dAn unhandled exception has occurred.D08d9An unhandled exception has occurred.D4bb2An unhandled exception has occurred.Daf10An unhandled exception has occurred.Dc2a0a6698e9e

Request path: /_admin/sssvc/ManageSSSvcApplication.aspx

User host address:
User: CORP\xxxxx
Is authenticated: True
Authentication Type: NTLM
Thread account name: TEST\spfarmsvc

Leland Usher SharePoint Developer/Administrator
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