views:

139

answers:

3

I was hoping it was as easy as referencing my existing libraries to use them with WP7. However, it complains about not able to load them because of .Net CF when I actually use them.

Do i need to recompile them to .NET CF or something?

I thought the big plus of WP7 was: leveraging your existing codebase...? How can I leverage my existing codebase if I need to strip everything out of it and maintain multiple versions?

+1  A: 

Yes, you need to start up a windows phone library (which has references to the netcf bcl) ... you can add most all of your files as linked file references. This lets you change one source file and each platform will automatically be updated once you compile.

Look up some of XNA tutorials/videos that talk about how to have cross platform games for an example of how to do this

Joel Martinez
Sounds as a good acceptable solution. Will try.
Peterdk
Am I right in that you can't link multiple files at once? But need to link them one by one?
Peterdk
I'm pretty sure you can link multiple files at once as long as they're in the same folder. Just bring up the add existing file dialog, ctrl+click each file you want to add, then choose "Add as Link"
Joel Martinez
Be very careful if you are relying on existing code, Silverlight on Windows Phone may not allow you to use non-Silverlight 3 libraries in your Project, if you get a warning when adding a reference this may be an indication that library may not work on the device.
RoguePlanetoid
Yes, @RoguePlanetoid is right, that's why you'd have to recompile your code against a project which has the correct bcl references
Joel Martinez
+1  A: 

The .NET Compact Framework is a subset of the full .NET Framework with some additional niceties for mobile development. If you want to compile a library for Windows and Windows Phone, you need to build your code for each platform.

You can still leverage much of the same code you used for your .NET library, but you will need to use preprocessor symbols and conditional compilation to exclude functionality for the desktop (or phone) that is not supported in the other framework.

To do this: create two projects. One project will contain all of your files targeted for the desktop framework. The other will contain linked versions of your files for the compact framework. You can define symbols in each project in order to trigger conditionally compiled blocks of code.

This means that any investment you have already made in .NET will be easily translated into the Windows Phone world, but you also want to be sure that the performance characteristics of your library will be easily supported by a less-powerful device.

Best of luck!

Ed Altorfer