Friday, May 15, 2009

Sharing Code between .Net and SilverLight

Don’t Write code 2x, once in silver light once in .Net. Share code between the two platforms. Silverlight is looks lie .net but isn’t .net. We want to write code 1x and be used on client and server. Choices are: duplicated files, linked files, Project file management(dual project files). He recommends linked files. When adding a server class to client, don’t click add to project, use dropdown and select add as link. It will build class 2x once on client and on server. Tho not all code can be shared. Code written carefully should be able to be used on both. Techniques for non-shared, Partial classes, compiler directives (# if SILVERLIGHT), inheritance ( tho not recommended). Shifting some code from service to partial class. You will most likely need to do both partial class and SILVERLIGHT directive. Look for Project Linker on Microsoft.com (feb 2009). Make sure all instances of VS are closed when installing. This will enable linking easier.(will add menu item to right click). Also will add edit links to project menu so you can remove.

No comments:

Post a Comment