So you want to add a Normal Class Library Project to a Silverlight application, you think to your self how hard could this be despite the Visual Studio Warnings. Well for the most part its fairly simple, however there are a number of problems that I faced when doing exactly that.
Thanks to Neil Mosafi’s post on converting class library project for Silverlight consumption, I found 2 methods of doing the conversion.
1.) Create a NEW Silverlight Class Library Project and then ADD your EXISTING code files to the project
2.) Hack the csproj file to change its signature (details are courtesy of Neil Mosafi’s post) VS.NET 2008 believes that its a Silverlight Project (don’t forget the changes needs to be made to both the DEBUG as well as RELEASE sections)
Initially I went about making these changes using method 2 however I kept finding a number of issues relating to duplicate references , especially with the HttpWebRequest object and a few other things.
I also needed to change all non generic collections to use their generic equivalents as all non generic collections are not included in Silverlight 2.0
The Serializable attribute is not part of the coreclr, therefore it has to go, XML Serialization is your friend. Rockford Lhotka has started work on an alternative to the Serializable attribute however its extremely limited at this stage, The Silverlight Serializer may suit your needs so do check it out.
The project I was playing with also used a little bit of XPath Navigation and some other System.XML namespace classes that are not part of the cut down version, so I have to change the code to use Linq to XML
There were a whole bunch of other things that I fixed up and was good to go when I realized that the project changes were not referencing the correct mscorlib and system.xml libraries, however the compiler did not seem to mind to much which baffled me. At this point I decided that the safer way was to go down option 1, simply because I thought it would give a much better jumping off point, lo and behold it has. I am pretty close to having it compile correctly for the Silverlight application which I intend to share.
At the end of this all my advice in converting is to go with method 1, as its just much more fool proof.





Hello!
Very Interesting post! Thank you for such interesting resource!
PS: Sorry for my bad english, I’v just started to learn this language
See you!
Your, Raiul Baztepo
It is very interesting and so informative blog commenting post and it is useful to my knowledge and can get good knowledge and i also developed my information.