Since SL != .NET, you'll need to compile them in a Silverlight assembly, using the Silverlight compiler. In other words, you can't directly consume them without a little trickery.
One option is to create a Silverlight project, then use file-linking to share code-files from the .NET project (wihtout duplicating them). A normal project owns the files contained within it, but a "linked" file is included for compilation without being fully owned by the project. Files are linked by going to "Add File > Add Existing File" dialog, look to the bottom right, and you'll see that you can "link" an existing file.
What you can then do:
- Have your normal .NET project, with your .cs files
- Have a Silverlight project, which links to your first projects code files
When you compile the Silverlight project it will treat the linked files as though they belong to the SL project (but on your drive there is only a single copy, inside your .NET project).
A challenge you may run into is that not all .NET types are supported in Silverlight, so if your business objects contain these then your .NET code might not compile under silverlight. You can use pre-compiler directives to have 2x method signatures for these cases: 1x .NET, and 1x SL compatible. Your would set the directive (ie: Silverlight==True
) and the compiler would choose one or the other.
For example:
#IF SILVERLIGHT
public void SomeMethod(SilverlightType someParam)
#ELSE
public void SomeMethod(SomeDotNetType someParam)
#ENDIF
Here's a link with a walkthrough from Rocky Lhotka (author/CSLA.net framework designer). He mentions using linked files and/or partial classes to selectively compile for each platform.