Porting from CE to Desktop

M

mcm

I see lots of discussion regarding people trying to port a desktop app to Windows CE. But I'm trying to go the other way.

I have a relatively mature application running on Windows CE 5.0 (built with C# .NET and Visual Studio 2008).

The CE application collects data and displays the results. It uses dozens of "fuill screen" (640x480) forms and all of the graphics are GDI+. There isn't anything that is CE specific in the code.

I'd like to (quickly and easily) build a desktop version of the same application so that I can have an offline data viewer.
Unfortunately, I don't see anything in Studio 2008 wherby I can click a magic button that builds a desktop compatible EXE file that runs in a 640x480 window.

What is my best (i.e. quickest and easiest) approach for gettting this thing running on my desktop?
Ideally, I'd like the CE and desktop apps to run from the same code base so that revisions will apply to both platforms.

Thanks,

- Mark
 
C

Christopher Fairbairn [MVP]

Hi Mark,

mcm said:
What is my best (i.e. quickest and easiest) approach for gettting this
thing running on my desktop?
Ideally, I'd like the CE and desktop apps to run from the same code base
so that revisions will apply to both platforms.

Assuming you are not referencing any Windows CE or .NET Compact Framework
specific assemblies you should be able to run your .NET CF build on your
desktop without modification.

The .NET CF target builds your assemblies with the retargetable
(http://msdn.microsoft.com/en-us/library/system.reflection.assemblynameflags.aspx)
flag which enables the compiled assemblies to run against the desktop
version of the base class libraries.

It's worth a short - just go into the output directory and double click on
the main executable. However in my experience although this is possible most
applications will still need some platform specific "spit and polish" to get
them working 100%.

Daniel Moth's "Write Code Once For Both Mobile and Desktop Apps" article
available on MSDN Magazine at
http://msdn.microsoft.com/en-us/magazine/cc163387.aspx may have some
additional information that will help with this.

Hope this helps,
Christopher Fairbairn
 
M

mcm

Thanks Christopher,

I'll read the article - looks helpful at first glance.

Do you know if this provides debug capabilities across both platforms?
As far as I've seen; once you chose a mobile platform, Studio 2008 doesn't (intutively) show you a place to switch to a desktop platform for debugging.


- Mark
 
P

Paul G. Tobey [eMVP]

You can't do some sort of a switch in VS to debug on a different class of
targets. And, for that matter, it wouldn't be valuable. If the code fails
on the .NET CF, it's just as likely to work fine, or at least differently,
when run against the .NET Framework. If you build a new project to target
the desktop framework and add your existing source code to that new project,
you can run/debug it on the desktop with full Framework support, of course.

Paul T.
 
C

Christopher Fairbairn [MVP]

Hi,

mcm said:
Do you know if this provides debug capabilities across both platforms?
As far as I've seen; once you chose a mobile platform, Studio 2008
doesn't (intutively) show you a place to switch to a desktop platform for
debugging.

This was a feature that was in some of the betas for Visual Studio 2005 but
was removed before release. Daniel Moth has a blog post about how it may be
possible to re-enable this unsupported feature at
http://www.danielmoth.com/Blog/2005/01/deploy-to-my-computer.html, but I
have never tried it and don't know if it still works.

As Paul Tobey has suggested an easier and more supported approach is to
create two projects within your solution. One for your PDA target platform
and one for your desktop.

You should be able to easily share all your source code between these two
projects so a change in one instantly makes its way into the other build. To
do this when you use the add file dialog to add your existing source code to
the desktop project make sure you click on the drop down arrow on the right
hand side of the add button and select "add as link".

This techniques has additional advantages. For example its now possible to
add desktop or PDA specific source files to work around any desired changes
in functionality between the platforms and/or to work around missing
features.

Hope this helps,
Christopher fairbairn
 
M

mcmalburg1

OK - I've made some really good progress thanks to your help.
However, I just ran into an issue that I'm struggling with. I'm
starting with a "good" CE application. Which uses a bunch of things
like timers and fonts.

In "MyMainForm.Designer.cs" my original CE version had some things
like these
this.timerStatusUpdates = new System.Windows.Forms.Timer();
this.mainButton1.TextFont = new System.Drawing.Font("Tahoma",
8F, System.Drawing.FontStyle.Regular);


When I created a new desktop project and added the files as links,
these lines in designer.cs were magically transformed intto:

this.timerStatusUpdates = new System.Windows.Forms.Timer
(this.components);
this.mainButton1.TextFont = new System.Drawing.Font("Tahoma",
8F);

This magical transformation was very nice - and I was able to get a
desktop version running quite easily. Apparently Studio 2008 knew
that the full framework has different constructors. HOWEVER, since
the code changed, I now get about 100 errors when I try to build the
CE version.

'System.Windows.Forms.Timer' does not contain a constructor that takes
'1' arguments
'System.Drawing.Font' does not contain a constructor that takes '2'
arguments


Help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top