views:

55

answers:

3

Our team is developing a framework. In a different solution, we have a mobile project (along with other "normal" .NET projects). That mobile project would benefit from using some of the code in the framework. However, the framework is the full .NET version, not the compact framework. How should the mobile project use that framework code? Right now, our team has added many files in the framework to the mobile project via linked files. We can do this, but I'm wondering if there is a better way. With this approach, we have to take some extra steps on the build machine to make sure those linked files are available when we build the solution with the mobile app in it.

Another option is to maintain two versions of the framework classes; one as the full .net version, and another as the compact framework version. But maintaining duplicate code is never good.

A: 

maintaining two versions of the classes is going to be a management nightmare. You could reference the full .NET version assemblies from the .NET CF project but there's no way to guarantee all the required methods & assemblies will be available on the mobile device.

You should create a common project that targets the .NET CF framework and put all classes that are needed by both projects/products in there, and then reference this common project in your mobile project and your other project that uses the full version of the .NET framework.

hjb417
A: 

We are doing .NET Full and CF development. We do more or less what you are doing, with a little tweak. Usually, a project needs two solutions: One for the desktop application (Full .NET) and one for the mobile application (CF .NET).

Sometimes we need to share code between the two applications. We create a separate class library for that code and a second class library that ends in "Compact" and contains the "linked" files from the full .NET class library. For example:

My.Desktop

My.Mobile

My.Common

My.Common.Compact

My.Common.dll is referenced by My.Desktop and My.Common.Compact.dll is referenced by My.Mobile.

One more tip. Sometimes, the code in My.Common doesn't work exactly as is in My.Common.Compact cause CF is missing a lot of code that exists in Full .NET. To overcome this, we use #if statements with a FULL_FRAMEWORK directive that is only defined in My.Common and we make sure is not defined in My.Common.Compact.

Petros
A: 

Someone actually sent me an MSDN link on exactly this subject. The bottom line is for the two projects (full framework and CF) to share the same folder, then share the same files (but each project can pick and choose which files they want).

http://msdn.microsoft.com/en-us/magazine/cc163387.aspx

Bob Horn