Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Silverlight 2.0 beta 1, System.Runtime.Serialization. Bombing on custom object?
8 replies. Latest Post by xsirxx on December 4, 2008.
(0)
xsirxx
Member
28 points
40 Posts
04-28-2008 4:08 PM |
Hi everyone, first time poster here! Just wanted to say thanks in advance for any help!
Ok here is my problem. I have a Silverlight 2.0 beta 1 project and have a website project, a silverlight application project, and a silverlight control library project all in my solution. When I create a WCF service under my web site project everything runs fine. Now If I create a custom object with the DataContract and DataMember attributes under the website and use it as an input value to a WCF call it still runs fine. Now If I create a custom object under my silverlight control library and use it as an input into the WCF service it bombs out with this error:
I cant seem to get around this issue. I would like to have my business objects seperated out from the website and under their own library but I cant seem to serialize the objects this way. Also I cant find what version of System.Runtime.Serialization is contained in System.Web.Silverlight.dll if indeed this is where it is located. Although building a silverlight website the old way, I see System.Runtime.Serialization to be of version 3.0.0 when the library is only allowed version 2.0.5.0.
I also cannot find a way to force 3.0.0 of System.Runtime.Serialization in my silverlight control library, it uses 2.0.5.0.
Any help would be greatly appreciated!
Thanks,
Brad
Jabb
462 points
81 Posts
04-28-2008 9:04 PM |
First off, the base Silverlight assemblies are installed atC:\Program Files\Microsoft Silverlight\2.0.30226.2
You will find the Silverlight System.Runtime.Serialization.dll in the above directory.
These assemblies are designed to run on the Silverlight CLR; you cannot mix assemblies from the .NET Framework and the Silverlight Framework, which means you cannot share assemblies across the two frameworks.
04-28-2008 11:12 PM |
That is interesting because when I start a new project(using the selection Web Site on the second menu), it starts 2 projects in one solution for me. The Website and the silverlight application. The website uses System.Web.Silverlight.dll "C:\Program Files (x86)\Microsoft SDKs\Silverlight\v2.0\Libraries\Server\". The application uses c:\Program Files (x86)\Microsoft Silverlight\2.0.30226.2\System.Runtime.Serialization.dll. The problem is the website is using what I believe is .NET 3.0 System.Runtime.Serialization while the silverlight application project is using 2.0.5.0. I cannot add the reference of "C:\Program Files (x86)\Microsoft SDKs\Silverlight\v2.0\Libraries\Server\System.Runtime.Serialization.dll" into the website project
This difference is what I believe is causing all these issues. I can take the EXACT class and move it into my Website project and it runs absolutely fine. It is only after I call the DataContractSerializer that it bombs.
Hope this helps any misunderstandings, sorry about that.
-Brad
04-29-2008 12:18 AM |
The System.Web.Silverlight.dll assembly is a .NET 2.0 server-side assembly containing, among other things, the SilverlightPlugin class that your ASPX uses to render the HTML Silverlight plugin code.
So yes, the website that the Silverlight Application template targets the .NET Framework, while the actual Silverlight Application targets the Silverlight Framework.
04-29-2008 6:27 PM |
I cant manage to get any type of serializing to work on my WCF server. I try to use XmlSerializer to deserialize on the WCF server side(Service Contract) but it says it cannot find System.Xml.Serialization 2.0.5.0. So I include it by selecting "Copy Local", and it says that it is already included in another location at runtime and bombs. So I try to push the deserialization function on the actual object itself but it bombs this time without an actual exception. The string looks correct that is being sent over.
So I ask this, if anyone can help me by trying a few things out I would GREATLY appreciate it.
Would someone be willing to test a new project created with the Silverlight Application template, and on the second option select Website. Create a FooBar object with just one field under the application side and either try to serialize it with a DataContract or on your own with XmlSerializer. Then create a WCF Service on the Website project and make reference to it. Now try to use the input parameter in your WCF function as the FooBar object. Run a Async command to the service.
I cant seem to get this to deserialize on the WCF server side. Matter of fact I cant seem to get ANY custom object whatsoever to deserialize on the server side. Now understand I can use any built-ins just fine ie.(String, int, bool, byte...).
Again I would greatly appreciate any help whatsoever, as I have been working on getting serialization working under WCF for a couple of weeks.
Thanks again,
04-29-2008 7:49 PM |
BTW I just wanted to throw an update out there that if I create another porject in my solution as a Class Library, it wont work and gets the same error not being able to find Serialzation library of 2.0.5.0. BUT, if I switch out the Serialzation dll out of my class library for the 3.0.0 version then it runs perfect. Only problem now of course is a silverlight application cannot use class library classes because they arent built under silverlight. So I have to use a reference to the library through Add Web Service....
Yi-Lun L...
All-Star
25052 points
2,747 Posts
04-30-2008 12:17 AM |
Hello, try those steps:
Optional: These steps only needs to be done if you want to put your business object classes in a separate assembly.
Required: These steps are required.
russau
10 points
23 Posts
12-03-2008 11:22 PM |
hi, did you have any luck with this? it seems the wcf service wants the DataContract / DataMember attributes. when you add these attributes to a silverlight library class you are using the attributes from the silverlight System.Runtime.Serialization.dll (2.0.5.0). which the wcf service doesn't recnogise.
it appears this problem goes away in .net 3.5 sp1 - http://www.pluralsight.com/community/blogs/aaron/archive/2008/05/13/50934.aspx
russ
12-04-2008 9:40 AM |
I have found ways around it but yes 3.5 SP1 helped greatly.... I have gone that route for serializing through WCF. For Sockets I simply copy my code over for packet classes that are being serialized then mark the attributes the same on those.... Its redundant but it works.