views:

49

answers:

1

hi, i have a web application with different business objects. i want to start developing a sliverlight application that is using some of these objects but i can't reference my business objects library cause it's not a sliverlight class library. now i guess i need to call web services to from my silverlight application but what type objects should they return? what would be the best way to use my business objects in the silverlight app without writing a new class lib which will be the about the same as the .net lib? let's say i have a .net class:

public class User
{
  public int Id{get; set}
  public string Username {get; set}
  public string Email {get; set}
}

the silverlight class should be the same how do i use this object without rewriting it as a sliverlight class?

+2  A: 

The easiest way to do this is to add a file reference/link in visual studio from your silverlight project to your user class' .cs file.

  1. Right click on a folder in the SL folder
  2. Pick Add "Existing Item"
  3. Find your class (presumably user.cs)
  4. Instead of clicking on the "add" button, there's a little down arrow just to the right of the arrow (it's not super noticeable). If you click it, a dropdown menu shows up and one of the options is "Add as link"

Now, your class is referenced by both projects, and compiled with both projects. And if you change it in one, then the other will get the same change :-)

Joel Martinez