Error re-serializing a soap class

I have a web service that defines a class that is returned to the calling 
program. Nothing special or complicated, mostly string.

The calling program then tries to serialize the returned class using the 
XmlSerializer and I recieve a InvalidOperationException. Additional 
Information: there was an error reflecting type xxxx.

	ser = new XmlSerializer( typeof(JLConfigService.CJLOperatorInfo) );
	data = new StreamWriter( "L:\\OprInfo.xml" );
	ser.Serialize( data, sd.OprInfo );
	data.Close();

Both the client and the server are .net 3.5.

There is a lot of decoration on the class definition that I really know the 
implication of.

    [System.Diagnostics.DebuggerStepThroughAttribute()]
    
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]
    
[System.Runtime.Serialization.DataContractAttribute(Name="CJLOperatorInfo", 
Namespace="http://NorSoftConsulting.com/")]
    [System.SerializableAttribute()]
    public partial class CJLOperatorInfo : object, 
System.Runtime.Serialization.IExtensibleDataObject, 
System.ComponentModel.INotifyPropertyChanged {
        

So how do you serialize this class? Soap must have been able to both 
serialize and deserialize this class just to transmit it.

-- 
Scott Norberg
0
snorberg (10)
3/2/2009 3:12:03 PM
dotnet.xml 7266 articles. 0 followers. Follow

3 Replies
984 Views

Similar Articles

[PageSpeed] 2

Scott wrote:
> I have a web service that defines a class that is returned to the calling 
> program. Nothing special or complicated, mostly string.
> 
> The calling program then tries to serialize the returned class using the 
> XmlSerializer and I recieve a InvalidOperationException. Additional 
> Information: there was an error reflecting type xxxx.
> 
> 	ser = new XmlSerializer( typeof(JLConfigService.CJLOperatorInfo) );
> 	data = new StreamWriter( "L:\\OprInfo.xml" );
> 	ser.Serialize( data, sd.OprInfo );
> 	data.Close();
> 
> Both the client and the server are .net 3.5.
> 
> There is a lot of decoration on the class definition that I really know the 
> implication of.
> 
>     [System.Diagnostics.DebuggerStepThroughAttribute()]
>     
> [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]
>     
> [System.Runtime.Serialization.DataContractAttribute(Name="CJLOperatorInfo", 
> Namespace="http://NorSoftConsulting.com/")]
>     [System.SerializableAttribute()]
>     public partial class CJLOperatorInfo : object, 
> System.Runtime.Serialization.IExtensibleDataObject, 
> System.ComponentModel.INotifyPropertyChanged {
>         
> 
> So how do you serialize this class? Soap must have been able to both 
> serialize and deserialize this class just to transmit it.

DataContractAttribute and .NET 3.5 suggests you are using WCF. Try to 
serialize using DataContractSerializer (in the namespace 
System.Runtime.Serialization) not using XmlSerializer.




-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
0
mahotrash (1777)
3/2/2009 3:24:16 PM
Thanks Martin! This got me on the right track.
-- 
Scott Norberg


"Martin Honnen" wrote:

> Scott wrote:
> > I have a web service that defines a class that is returned to the calling 
> > program. Nothing special or complicated, mostly string.
> > 
> > The calling program then tries to serialize the returned class using the 
> > XmlSerializer and I recieve a InvalidOperationException. Additional 
> > Information: there was an error reflecting type xxxx.
> > 
> > 	ser = new XmlSerializer( typeof(JLConfigService.CJLOperatorInfo) );
> > 	data = new StreamWriter( "L:\\OprInfo.xml" );
> > 	ser.Serialize( data, sd.OprInfo );
> > 	data.Close();
> > 
> > Both the client and the server are .net 3.5.
> > 
> > There is a lot of decoration on the class definition that I really know the 
> > implication of.
> > 
> >     [System.Diagnostics.DebuggerStepThroughAttribute()]
> >     
> > [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]
> >     
> > [System.Runtime.Serialization.DataContractAttribute(Name="CJLOperatorInfo", 
> > Namespace="http://NorSoftConsulting.com/")]
> >     [System.SerializableAttribute()]
> >     public partial class CJLOperatorInfo : object, 
> > System.Runtime.Serialization.IExtensibleDataObject, 
> > System.ComponentModel.INotifyPropertyChanged {
> >         
> > 
> > So how do you serialize this class? Soap must have been able to both 
> > serialize and deserialize this class just to transmit it.
> 
> DataContractAttribute and .NET 3.5 suggests you are using WCF. Try to 
> serialize using DataContractSerializer (in the namespace 
> System.Runtime.Serialization) not using XmlSerializer.
> 
> 
> 
> 
> -- 
> 
> 	Martin Honnen --- MVP XML
> 	http://JavaScript.FAQTs.com/
> 
0
snorberg (10)
3/2/2009 4:44:34 PM
Hello Scott, 

Yes, if we are using WCF, the DataContractSerializer is the default and 
recommended way to serialize and deserialize .NET objects. The 
DataContractSerializer has many advantages. The most important one is about 
10% performance improvement. 

The only situation we go back to use XmlSerializer is that we want to fully 
control how the generated xml looks. 

Here is a nice article which compares the XmlSerializer and 
DataContractSerializer,
http://www.danrigsby.com/blog/index.php/2008/03/07/xmlserializer-vs-datacont
ractserializer-serialization-in-wcf/

You can find some sample codes about how to serialize and deserialize with 
DataContractSerializer in the following MSDN magazine article,
http://msdn.microsoft.com/en-us/magazine/cc163569.aspx

For your convenience, I post the sample codes here,

static void WriterPersonSerializable()
{
    Person p = new Person("Bob", 34, "secret");
    p.spouse = new Person("Jane", 33, "secret");

    using (FileStream fs = new FileStream("person.xml", FileMode.Create))
    using (XmlDictionaryWriter writer =
        XmlDictionaryWriter.CreateTextWriter(fs))
    {
        DataContractSerializer serializer =
            new DataContractSerializer(typeof(Person));
        serializer.WriteObject(writer, p);
    }
}

static void ReadPersonSerializable()
{
    using (FileStream fs = File.OpenRead("person.xml"))
    using (XmlDictionaryReader reader =
       XmlDictionaryReader.CreateTextReader(fs))
    {
        DataContractSerializer serializer =
            new DataContractSerializer(typeof(Person));
        Person person = (Person)serializer.ReadObject(reader);
        Console.WriteLine("{0} is married to {1}",
            person.Name, person.spouse.Name);
    }
}


Please let me know if you have any future questions on this. I am glad to 
be of future assistance. Have a nice day, Scott!


Best regards,
Colbert Zhou (colbertz @online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and 
suggestions about how we can improve the support we provide to you. Please 
feel free to let my manager know what you think of the level of service 
provided. You can send feedback directly to my manager at: 
msdnmg@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to 
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues 
where an initial response from the community or a Microsoft Support 
Engineer within 1 business day is acceptable. Please note that each follow 
up response may take approximately 2 business days as the support 
professional working with you may need further investigation to reach the 
most efficient resolution. The offering is not appropriate for situations 
that require urgent, real-time or phone-based interactions or complex 
project analysis and dump analysis issues. Issues of this nature are best 
handled working with a dedicated Microsoft Support Engineer by contacting 
Microsoft Customer Support Services (CSS) at 
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

0
colbertz (6)
3/3/2009 8:02:59 AM
Reply:

Similar Artilces:

Re: Money Not Handling Like Transactions the Right Way
Carl, tks for your reply. - I believe this problem is within MS Money, and how it is perceiving two like transactions when it downloads transaction from my checking account. Following germane: - This is not QIF statements, it is the automatic downloading of transactions from my bank. I provide MS Money the username and password, and it downloads the transactions. SOP. - The monthly transfers are from my checking account to T. Rowe Price via monthly debit set up long ago. - Both individual transactions show up properly when I access my checking account via my bank website - Both t...

error message 12-03-09
Every time I try to open a url from an email message, I get an error message telling me that window can not open it. But if I click off the error message and try to open the url again, it will open. Any body know why?? Thanks Actually the error message states that "Windows can not find the URL." thanks, dljfnp "dljfnp" wrote: > Every time I try to open a url from an email message, I get an error message > telling me that window can not open it. But if I click off the error message > and try to open the url again, it will open. Any body know why?? ...

Error Code 2046 when sending emails.
Hi I have an Access 2003 database which is used to maintain membership records for a charity. On a member's record there is a button which sends an email to the member. On my new computer I have windows 7 home premium and I am using Windows Live email linked to my ISP. This worked fine on my old computer with Windows XP and Outlook Express. When I click on the button I now get the message Error Code 2046 The Command or Action SendObject isn't available now. The code is: Private Sub btnEMail_Click() Dim vMessage As String On Error GoTo ErrorCode ...

Outlook 2003 error Ox8004210B
When sending an attachment > 600KB the message does is sent but does not leave the outbox. On the next cycle it sends again but error messag 0x8004201B is received. Outlook continues to send the message but never takes it out of the outbox. I have to manually delete it. Needless, to say the receiver has now received mulitple copies of a LARGE email and is ready to kill me. KBA 315049 references the problem but teh solution therein doesn't solve it. Anyone else having the same issues. I've seen it on other forums but havent' seen a viable solution yet except to sen...

Problem with Validation Error
I have a form with a textbox control bound to a table field. The table has no validation properties set for this field; the field is indexed with 'No Duplicates'. The textbox itself has no validation properties set for the field. I have the following code in the textbox's BeforeUpdate event: If Not (txtCARDocNumber Like "C####") Then MsgBox "The CAR Number must be in the format 'Cnnnn'," & vbNewLine _ & "where n is any numeric character." _ , vbExclamation + vbOKOnly, "CAR Number Format Inco...

Closing opportunity error
When I try to close an opportunity, I am getting an error message instead of the 'close opportunity' web page dialog. It seems that the error relating to an invalid value (null) from the database. A user with admin rights Added, deleted, and changed the opportunity form fields multiple times. He also deleted all 'Status Reason' field values and later added custom them back. (Setting -> System Customization -> Opportunities-> Customize Form -> Administration tab -> Status Reason Field Properties -> Values tab.) I think that the error has something to do with...

Error message consistently shows and shuts down entourage
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel Email Client: Exchange I get the following error message when I open entourage and then entourage closes itself down: Microsoft Sync Services has encountered a problem and needs to close. We are sorry for the inconvenience." Clicking the "More Information" button gives me the information I'll paste in at the end of this email. Please help me -- I googled the error but the answers were too techy for me to figure out. Right now I can't read/send emails or schedule meetings. Than...

Outlook 2007 totally disabled
1. MS Office 2000 installed on Vista OS. All email accounts, including Hotmail, operable using Outlook, with Outlook Connector. 2. Installed Enterprise 2007 and uninstalled (apparently not all of) Office 2000. 3. Accessing Outlook 2007 from desktop icon produces error "The Add-in "Outlook Connector Extenions" (msncon32.dll) cannot be loaded and has been disabled by Outlook. Please contact Add-in manufacturer for an update. If no update available uninstall the Add-in". 4. Now Outlook 2007 is totally inoperable, but displays previous Inbox emails, but Se...

Read CD Serial Number
I am looking for a way to read the serial number off of a CD that is currently in a given drive. I'm assuming that there is a way to get this info, as it is used by CD-Player applications to determine which disc is currently inserted and to be able to retrieve the track listing from an associated database. I have also looked through the cdplayer.ini file and I see a specific number listed for each CD in the file. Any help you can give me on this would be wonderful. Thanks. - Robert Go to any search engine and type the following in the search box "read CD serial number&quo...

Publisher 2000 Error Message when saving work
I have been using this program to publish a club newsletter for approz 1 year. Starting tonight the program will no longer let me save my changes to a file - and gives an error message. I have tried reloading and restarting the program. Have also used the command under Help to repair the file. Nothing is working. Any suggestions? I appreciate the help! Are you using the same Newsletter over and over? Bad idea... What is the exact error? How to troubleshoot a damaged publication in Publisher http://support.microsoft.com/default.aspx?scid=kb;en-us;198256 -- Mary Sauer MSFT MVP h...

error C2248: 'Recibr::~Recibr'
Hi. I woul like than my class class Recibr : public CCmdTarget { DECLARE_DYNCREATE(Recibr) Recibr(); // protected constructor used by dynamic creation protected: virtual ~Recibr(); ... } handles ON_COMMAND messages To achive so, I declared CMainFrame::CMainFrame() { .... Recibr m_Recibir } and I've also modified BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) { // let the view have first crack at the command if (m_wndView.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo)) return TRUE; // line add to attempt to classs Rec...

Error after setting default pricelist
Hi, In the opportunity form, i added javascript code in order to input default the pricelist value automatically. When loading the form, the default pricelist was successfully added. However i could not add the new opportunity product. The error was " you have changed the pricelist for the opportunity. Please save the opportunity form before attempting to add the product." I have save the form several times but still cannot add the product. What's wrong? Carrie ...

Class/resource link
Hi all Using Visual Studio.net 2003. When I insert a new dialog, i can right click on the dialog, and add a class, fine. When I have added the class, I can right click on a control to add a variable. The "add class" wizard automatically knows in which file to add the new variable. But where is this information stored? There are a couple of reasons I ask. First, I have converted some of my old projects, and I cannot add variables. I also added a new class, and afterwards I moved the class files to another directory. Now I cannot add variables unless I delete the class files and run...

security setup for user class copied to another company
We have 3 companies in GP- version 9 - we have a user class set up and want to copy the security settings to the other companies. I was told it could be done through advanced security - is that correct? Do we use the import/export function? Thanks. User Classes are a system wide setting. Once you assign the user to the class, and grant the user access to a company, their security will follow them to that company. Best regards, -- MG.- Mariano Gomez, MIS, MCP, PMP Maximum Global Business, LLC http://www.maximumglobalbusiness.com The Dynamics GP Blogster at http://dynamicsgpblogster.bl...

"Too many fields defined" error message
I received a "Too many fields defined" error message when importing an Excel 97 spreadsheet into SQL Server 2000. There are 256 columns in the Excel 97 spreadsheet, all containing data. How do I correct this in Excel 97? It's a bug. There's a bit of information in the following MSKB article: BUG: Cannot Import Excel 97 Spreadsheet with 256 or More Columns http://support.microsoft.com/default.aspx?id=207446 Godzilla wrote: > I received a "Too many fields defined" error message when > importing an Excel 97 spreadsheet into SQL Server 2000. > There ...

tprinter error when using same printer as printer1 and printer2
I have a toy store. I have created a custom 40 column receipt template that I would like to print after each transaction (in addition to the standard 40 column receipt). This custom receipt goes in the customer bag, and is handed to the gift wrapper, where they use the custom receipt as a "gift wrap guide". I have the receipt the way I like it. Now, I would like to add this to the transaction process, by activating "printer2" with the identical setting as "printer1", except using the custom template, rather than the default 40 column which is set on pri...

CRM 4.0 Installation error #3
Hi, i am trying to install Dynamics CRM4.0, but I get an error in the setup check. The error is: Service msftesql$CRM was not found on computer 'CRMSERVER'. The specified service does not exist as an installed service I checked in the help what can I do and it say that the possible reasons for this error are: 1. SQL Server FullText Search service is not running 2. You do not have sufficient rights I check the SQL Server FullText Search service and it is up and running. I am installing the CRM server as Administrator and I do not believe that i do not have rights or permissions....

Error 13 Type Mismatch 03-07-10
Need help solving a type mismatch error on the following code: Many thanks! Private Sub Form_BeforeUpdate(Cancel As Integer) 'Limits the number of records allowed 'based on the field FloorProgMaxObservations If DCount("*", "tblFloorProgAudit", "[AuditID] = _ " & Me.AuditID.Value & "" And _ "[FloorProgCriteriaID] = " & _ Me.FloorProgCriteriaID.Value & "" And _ "[AuditorID] = '" & Me.AuditorID.Value & "'") = _ ...

Serial number error in Sales Transaction Entry
I noticed that one of my coworkers added a serial number (and invoiced it) into the Great Plains instead of allocating one of the existing ones. How do I return this serial number w/out affecting my inventory? I need to: 1. Return the item w/the wrong serial number. 2. Reinvoice the correct serial number. 3. NOT HAVE THE WRONG SERIAL NUMBER STUCK IN MY INVENTORY. How do I do this? ...

Criteria Query Error Please Help
I have a query with Criteria Between [Start Date] And [End Date] i t has been working fine until now. When I use start date 01-02-10 and end date 28-02-10 it returns an error 'this expression is typed incorrectly or is is to complex to be evaluated....' If I use any other dates i.e 01-01-10 - 31-01-10 it works fine, I can not see anything wrong with the data for the Feb dates. Thanks in advance V Have you declared the parameters As DateTime? If not the values entered could be misinterpreted as arithmetical expressions. You can declare them in design view or by a...

searching Chinese AccountName error
hi everyone, I meet a big problem, which can not retrieve the account data when i was trying to search a customer with chinese name(one chinese character is equal to 2 bytes). The data stored in the SQL is fine, also, i have found out the chinese name will be turned into the wrong translation like '?%%%?'. another question is how the CRM system connect to the SQL data base? ...

Error when adding user to CRM 4.0
We are running an evaluation copy of Microsoft CRM 4.0. I am trying to test out the multi-homed functionality but have been unable to add a user from another domain. I have a two-way Windows trust between the two domains and it is functioning properly. When I go to add the user from the other domain it finds the user and fills in the users details but when I go to save it throughs up a generic error: "An error has occurred. For more information, contact your system administrator." Any ideas? Can you enable DEV errors and post the error message? Darren Liu, CRM MVP Crowe ...

"Get/Change" Error message Safe Pay
We recently completed upgrading a customer from version 8 to version 10. We get the following error message when we reload transactions in safe pay. "A get/change first operation on table "ME_Void_Checks" failed accessing SQL data. Any help appreciated. Thanks Russ ...

COM Object (dll) Error
Hello, I created a new class (dll) using VB6.0 and placed it in the "C: \Program Files\Common Files\xxx" folder. I then added a reference to the dll in my access data project(adp). I reference the new class in the vba code for a form that uses the class to insert rows into a sql table, using a stored procedure. On the server I'm using for development, I make the ade and am able to run the application without error. So, I copied the ADE and dll to my virtual machine for testing. I put the dll in the same folder as on my development server and manually registered the dll using reg...

Mail Sending Error
We are using the script below to send an email upon closing a workbook. Some users are having issues on the .Send line and the email never gets sent. All users are on the same exchange server with the same domain with the same email program (Outlook 2003). Can anyone think of settings or issues that may prevent this from sending? With iMsg Set .Configuration = iConf .To = "email@domain.com" .CC = activepmeml .BCC = "" .From = activepmeml .Subject = trdcheck & " trade(s) ready for execution in " + ac...