C# class library, Silverlight class library , asmx

2019-08-12 08:06发布

问题:

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)

回答1:

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