
Today, many developers write code that should be executed by both Silverlight and .Net Runtime's. A good example is data validation, when you check them first on the client side using Silverlight, and then on the server side using .Net. Until recently, it was necessary to compile the same code into assemblies for different runtime's (Silverlight and .Net). This model is workable, but not perfect!
We called this new feature “assembly portability”, which allows you to port written code between Silverlight and .Net, which allows you to build code into an assembly using Silverlight tools, and then use the assembly you just assembled in both runtime.
')
I want to pay attention, this opportunity
does not change the basic mechanisms of code execution in Silverlight and .Net runtime! If you write code that uses APIs common to two runtime's, then you can use the same set of builds to write applications. But how to find out which API is common?
We installed 5 key assemblies that are portable between Silverlight and .Net. (The Silverlight UI is of course not portable - there are fundamental differences between the Silverlight UI and WPF mechanisms.)
As usual, we faced a large selection of which scenario to choose. As a result, it was decided to allow porting assemblies from Silverlight to .Net, and not vice versa. The motivation for such a decision was the fact that Silverlight implements a subset of .Net assemblies and it becomes obvious that assemblies using this subset will work in .Net.
Another serious issue was the choice of assemblies that would work safely in both Silverlight and .Net. We considered most scenarios where portability can be useful and decided to start with the most basic ones. As a result, for .Net 4 and Silverlight 4 we have chosen only a set of low-level builds, which we think will allow you to make various interesting scenarios.
For SL 4 and .NET 4, we made it publicly available:
- Mscorlib
- System
- System.Core
- System.ComponentModel.Composition
- Microsoft.VisualBasic
Example in Visual Studio 2010
Create a project
Using Silverlight build in .Net
I want to note once again that there are many types in .Net that will still not be available.