I have coded a dll library using the basic utilities of C#. But for platform independence, I want to port it to silverlight. Is it possible? If possible, then how to do it?
Or do you guys have any other suggestion?
I have coded a dll library using the basic utilities of C#. But for platform independence, I want to port it to silverlight. Is it possible? If possible, then how to do it?
Or do you guys have any other suggestion?
If you build your DLL for Silverlight4, it can be referenced from a .NET-project; but not the other way round. See Sharing Silverlight Assemblies with .NET Apps.
Another method of sharing source code between SL and .Net is to use Linked files.
In your .net solution, add a silverlight library project.
Add>Existing Item>browse to the source files in the .net project, select them, click the little down-arrow on the 'add' button and select 'add as link'.
In a lot of cases, no modifications are necessary. In the instance that there is a minor discrepancy, use build flags and conditionals in source. e.g.
#if SILVERLIGHT
#else
#endif
This has worked out well for me, especially when I want to share a DTO library.
My suggestion is to create different project files (for .NET and SL). Then add the common files into each.
Many classes and methods are available on both .NET and SL, so it is possible to make the two projects share the same code.
This does not apply to all scenarios. For example, my open source project #SNMP uses UDP related classes, but SL does not have any UDP related things.
My personal choice is to limit the size of SL application and move necessary pieces into a backend WCF application.