Same library in desktop and compact framework

M

MarkusSchaber

Hello,

I want to write a .NET DLL (using c#) which is to be used in both
the .NET Compact Framework on Windows CE, and in the standard
framework on servers and desktop applications.

Which is the way to do that? Simply referencing a "normal" dll project
from a "smart device" application project does not work.

Thanks,
markus
 
D

DickGrier

You (often) can use the same source code. However, each must be compiled to
target the appropriate framework, Desktop or Compact.

You cannot do what you want. In general, the underlying microprocessor uses
a different machine language, and while the IL (Intermediate Language) that
Visual Studio compiles to may be interchangeable, the IL itself is compiled
into machine code before it is executed. This step is not intended to be
done at runtime, though JIT compilation may be used.

Also, the Compact Framework (as its name implies) is a subset of the full
framework on the Desktop. So, it is quite possible to use Desktop framework
types that are not included in the Compact Framework. And, there is no rule
that says that the IL for the Desktop and Compact Frameworks will be,
exactly, identical. I suspect, without actual knowledge to state this with
certainty, that there can be minor differences due to optimizations made for
each platform. The compilation process, naturally, validates the used of
the appropriate framework types vs. the target framework.

Dick

--
Richard Grier, Consultant, Hard & Software 12962 West Louisiana Avenue
Lakewood, CO 80228 303-986-2179 (voice) Homepage: www.hardandsoftware.net
Author of Visual Basic Programmer's Guide to Serial Communications, 4th
Edition ISBN 1-890422-28-2 (391 pages) published July 2004, Revised July
2006.
 
M

MarkusSchaber

Hi, Rick,

You (often) can use the same source code.  However, each must be compiled to
target the appropriate framework, Desktop or Compact.

Ah, I see, so I have to create two projects using the same source
files, and keep them in sync manually?
You cannot do what you want.  In general, the underlying microprocessoruses
a different machine language, and while the IL (Intermediate Language) that
Visual Studio compiles to may be interchangeable, the IL itself is compiled
into machine code before it is executed.  This step is not intended to be
done at runtime, though JIT compilation may be used.

AFAIK, the dlls always contain IL regardless of the framework
implementation, and regardless whether it is interpreted, JIT-
compiled, or AOT-compiled during installation.
Also, the Compact Framework (as its name implies) is a subset of the full
framework on the Desktop.  So, it is quite possible to use Desktop framework
types that are not included in the Compact Framework.  And, there is norule
that says that the IL for the Desktop and Compact Frameworks will be,
exactly, identical.  I suspect, without actual knowledge to state this with
certainty, that there can be minor differences due to optimizations made for
each platform.  The compilation process, naturally, validates the used of
the appropriate framework types vs. the target framework.

I know that the CF is limited. But most of my code is "self-
contained" (mostly data type definitions and some business logic), and
the rest uses only some basic funtionality which is available in the
compact framework (I browsed the docs to ensure that).

If it is true what you say, it is not easily possible to create
applications which are distributed over compact and non-compact
framework implementations, as you cannot share their data types..

This is much different to what I know from Java, where the smaller
editions really are subsets (plus some specific extensions API), and
only some pre-verification steps are to be added (which don't hurt
running that code on the desktop environment at all).

Thanks for your help,
Markus Schaber
 
D

DickGrier

What Michael said. Also make sure that the libraries (various types) that
are referenced in the two frameworks have the same functionality.

Dick

--
Richard Grier, Consultant, Hard & Software 12962 West Louisiana Avenue
Lakewood, CO 80228 303-986-2179 (voice) Homepage: www.hardandsoftware.net
Author of Visual Basic Programmer's Guide to Serial Communications, 4th
Edition ISBN 1-890422-28-2 (391 pages) published July 2004, Revised July
2006.
 

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