1

ASMX services do not have ability to reuse the Silverlight Class library and Silverlight application needs dedicated Class library and not the C# class library. So i had to duplicate the C# class library code to a Silverlight class library to work with my Silverlight application, now that was not the problem here. I would like technical answers(In depth if possible) to these questions

  • Why is it that Silverlight needs dedicated Silverlight Class library. Even though it runs above a layer on CLR

  • Methods on the ASMX service returns C# class library entities, why is this not castable to analogous silverlight class

  • How do i make the ASMX service work with same class library ( because the entities returned from webservice does not seem to display methods on them in the intellisense)

Deeptechtons
  • 10,945
  • 27
  • 96
  • 178
  • I do not have answers to your questions but a tip: do you know the "Portable Class Libraries"? It intend to solve exactly this problem: http://msdn.microsoft.com/en-us/library/gg597391.aspx – Leo May 07 '12 at 12:15
  • @Leo thanks for the tip but when i added reference to asmx service i am greeted with **ever loving alert box** `"This project does not support portable class library"` I think it is about time i ditch the asmx service – Deeptechtons May 09 '12 at 06:01
  • I was thinking more on adding just the class that your service returns to portable library but i think that would not work too... take a look at the answer to this question: http://stackoverflow.com/questions/3584381/class-libraries-silverlight-and-webservices - I would say it is a very good advice. I assure you that if you can abandon asmx, you will not regreat ;) – Leo May 09 '12 at 07:37
  • @Leo just took 5 minutes to convince my manager to ditch the technology that once ruled, `bye bye asmx` and Hello **WCF** :) – Deeptechtons May 09 '12 at 08:36

1 Answers1

0

OK here is the answer. Silverlight Class libraries are compatible with all .NET platforms (since they are stripped down version). Just do this compile the class library to assembly and then add reference (instead adding to the project).

  • Silverlight class library does additional references (to assemblies that target silverlight platform) behind the scenes hence silverlight also needs these references to work correctly

  • Create a instance of class again ( No simple way to do it)

  • Methods are actually meta data, they cannot be transported through wire in a webservice call. You can invoke the methods when objects are constructed again from data

Deeptechtons
  • 10,945
  • 27
  • 96
  • 178