p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Professional ASP.NET 2.0 AJAX ISBN: 978-0-470-10962-5 (http://p2p.wrox.com/forumdisplay.php?f=340)
-   -   Error Listing 6-17 -Cannot implicitly convert type (http://p2p.wrox.com/showthread.php?t=59776)

BarDev July 4th, 2007 05:17 PM

Error Listing 6-17 -Cannot implicitly convert type
 
I'm on chapter 6 and have done every example in the book and all have worked well. But, in listing 6-17 I'm receiving the following error.
  Cannot implicitly convert type 'System.Web.Script.Serialization.JavaScriptSeriali zer' to 'System.Web.Script.Serialization.JavaScriptConvert er'

This error occurs in the code that I have typed and the error also occurs in the code that I download from Wrox's website.

I would really like to get this working before I move forward. Is anyone else having this problem?

Any help is greatly appreciated.


Thanks
BarDev

DrToketee July 4th, 2007 09:15 PM

I have not tried this example, so this is just an educated guess from my reading only.

The GetAlbumJSON() method is typed to return an object, but the XmlInclude attribute upon it is forcing the XML serialization to produce the result to follow the XML schema of Album. This may be triggering some compilational need to have a converter to produce the JSON equivalent of Album when a JavaScriptSerializer is doing the serialization. ?

So one thing I would consider trying is to remove the XMLInclude attribute from this method and change its return type from object to Album. Also, make sure you did not have any converters specified in the chapter's web.config (those sections seem to have been all commented out).

Just a stab in the dark. Good luck.


BarDev July 5th, 2007 11:01 AM

Sorry for the confusion. It seems the book and the downloaded code were both correct. After looking closer at my code, I noticed the type was JavaScriptConverter but it should have been JavaScriptSerializer.

Thanks for the reply. Next time I will look a little harder before I ask for help


Thanks


All times are GMT -4. The time now is 01:50 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.