creating for CF and Winforms

F

Floyd Burger

I have a component that works great under Winforms, but I'd like to use it
under CF as well. It's doing a little P/Invoke to use some APIs that are
available in WinCE and Windows. What I'd like to do is have a single
assembly that will run under Winforms and CF so my SmartDevice application
can run on the PPC and the desktop. Is this possible?
 
F

Floyd Burger

I'm just talking about the assembly that contains my component. Anyway, I
just went thourhg some of the OpenNetCF source, and they're doing something
like what I want to do. It seems that you can create a regular C#
ClassLibrary and deploy/run it on a CF device as long as the .NET code is
using stuff that is CF compliant.

--
Floyd Burger


William Ryan eMVP said:
No, you'll need to create a seperate smart device application.
 
C

Chris Tacke, eMVP

Yep. Look at the IO.Serial stuff for a decent example of code that works on
both.

--
Chris Tacke, eMVP
Co-Founder and Advisory Board Member
www.OpenNETCF.org
---
Windows CE Product Manager
Applied Data Systems
www.applieddata.net


Floyd Burger said:
I'm just talking about the assembly that contains my component. Anyway, I
just went thourhg some of the OpenNetCF source, and they're doing something
like what I want to do. It seems that you can create a regular C#
ClassLibrary and deploy/run it on a CF device as long as the .NET code is
using stuff that is CF compliant.

--
Floyd Burger


William Ryan eMVP said:
No, you'll need to create a seperate smart device application.
use
 
W

William Ryan eMVP

Floyd:

I see you mentioned a component specifically and you've already found the
answer. I originally thought you meant create a single exe with forms that
ran on both. Sorry about the oversight.
Floyd Burger said:
I'm just talking about the assembly that contains my component. Anyway, I
just went thourhg some of the OpenNetCF source, and they're doing something
like what I want to do. It seems that you can create a regular C#
ClassLibrary and deploy/run it on a CF device as long as the .NET code is
using stuff that is CF compliant.

--
Floyd Burger


William Ryan eMVP said:
No, you'll need to create a seperate smart device application.
use
 
W

William Ryan eMVP

How can that be? Wouldn't you have to restrict everything that wasn't
supported on the cf ? I'm intrigued here though, and don't want to say it's
not possible if it is. How so?
 
L

Lloyd Dupont

very easy !


public static bool IsDevice
{
get { return Environment.OSVersion.Platform == PlatformID.WinCE }
}

public static int NativeFunc()
{
if(IsDevice)
return NativeFuncPPC();
else
return NativeFuncDesk();
}
[DllImport("kernel32.dll", EntryPoint="NativeFunc", SetLastError=true)];
extern static int NativeFuncDesk();
[DllImport("coredll.dll", EntryPoint="NativeFunc, SetLastError=true")];
extern static int NativeFuncPPC();

--
ihookdb
Get your data mobile
http://www.ihookdb.com
 
A

Alex Feinman [MVP]

Yes, something to that effect. In those days I have even written a
SqlGenericClient - a class that would go via SqlCeClient on the device and
via SqlClient over MSDE on the desktop. Like I said - cumbersome, but
possible

--
Alex Feinman
---
Visit http://www.opennetcf.org
Lloyd Dupont said:
very easy !


public static bool IsDevice
{
get { return Environment.OSVersion.Platform == PlatformID.WinCE }
}

public static int NativeFunc()
{
if(IsDevice)
return NativeFuncPPC();
else
return NativeFuncDesk();
}
[DllImport("kernel32.dll", EntryPoint="NativeFunc", SetLastError=true)];
extern static int NativeFuncDesk();
[DllImport("coredll.dll", EntryPoint="NativeFunc, SetLastError=true")];
extern static int NativeFuncPPC();

--
ihookdb
Get your data mobile
http://www.ihookdb.com


William Ryan eMVP said:
How can that be? Wouldn't you have to restrict everything that wasn't
supported on the cf ? I'm intrigued here though, and don't want to say it's
not possible if it is. How so?
found
the like
to
 
W

William Ryan eMVP

But wouldn't you have to call a totally different app? I understand doing
it with a library, but I thought the post meant a whole Windows app, so one
exe that could run (Including Forms) on windows or the CF? Totally
different libraries so what would you do once you determined the difference?



Lloyd Dupont said:
very easy !


public static bool IsDevice
{
get { return Environment.OSVersion.Platform == PlatformID.WinCE }
}

public static int NativeFunc()
{
if(IsDevice)
return NativeFuncPPC();
else
return NativeFuncDesk();
}
[DllImport("kernel32.dll", EntryPoint="NativeFunc", SetLastError=true)];
extern static int NativeFuncDesk();
[DllImport("coredll.dll", EntryPoint="NativeFunc, SetLastError=true")];
extern static int NativeFuncPPC();

--
ihookdb
Get your data mobile
http://www.ihookdb.com


William Ryan eMVP said:
How can that be? Wouldn't you have to restrict everything that wasn't
supported on the cf ? I'm intrigued here though, and don't want to say it's
not possible if it is. How so?
found
the like
to
 
L

Lloyd Dupont

No, no.
It' .NET world !

..NET code could be compiled once run anywhere *
(*) where .NET is supported.

so you compile on windows and run on FreeBSD with go-mono.

Anyway the compact version is a lean version of the full framework, and
what's compiled against it run everywhere out of the box (no recompile
necessary !)

however what's compiled against the full framework won't run on the PPC, for
many obvious and less obvious reasons ...

--
ihookdb
Get your data mobile
http://www.ihookdb.com


William Ryan eMVP said:
But wouldn't you have to call a totally different app? I understand doing
it with a library, but I thought the post meant a whole Windows app, so one
exe that could run (Including Forms) on windows or the CF? Totally
different libraries so what would you do once you determined the difference?



Lloyd Dupont said:
very easy !


public static bool IsDevice
{
get { return Environment.OSVersion.Platform == PlatformID.WinCE }
}

public static int NativeFunc()
{
if(IsDevice)
return NativeFuncPPC();
else
return NativeFuncDesk();
}
[DllImport("kernel32.dll", EntryPoint="NativeFunc", SetLastError=true)];
extern static int NativeFuncDesk();
[DllImport("coredll.dll", EntryPoint="NativeFunc, SetLastError=true")];
extern static int NativeFuncPPC();

--
ihookdb
Get your data mobile
http://www.ihookdb.com


William Ryan eMVP said:
How can that be? Wouldn't you have to restrict everything that wasn't
supported on the cf ? I'm intrigued here though, and don't want to
say
it's
not possible if it is. How so?
That is also possible but cumbersome

--
Alex Feinman
---
Visit http://www.opennetcf.org
Floyd:

I see you mentioned a component specifically and you've already found
the
answer. I originally thought you meant create a single exe with forms
that
ran on both. Sorry about the oversight.
I'm just talking about the assembly that contains my component.
Anyway,
I
just went thourhg some of the OpenNetCF source, and they're doing
something
like what I want to do. It seems that you can create a regular C#
ClassLibrary and deploy/run it on a CF device as long as the
..NET
code
is
using stuff that is CF compliant.

--
Floyd Burger


No, you'll need to create a seperate smart device application.
I have a component that works great under Winforms, but I'd like
to
use
it
under CF as well. It's doing a little P/Invoke to use some APIs
that
are
available in WinCE and Windows. What I'd like to do is have a
single
assembly that will run under Winforms and CF so my SmartDevice
application
can run on the PPC and the desktop. Is this possible?
 
A

Alex Feinman [MVP]

Bill,

Since CF assemblies are retargetable, you can actually compile a basic CF
form application and then launch it on the desktop. The moment you start
using CE-specific stuff, like SqlCE, InputPanel, MessageWindow and CE
P/Invokes, you need to wrap those calls into an extra layer of code to
prevent MissingMethodExceptions

--
Alex Feinman
---
Visit http://www.opennetcf.org
William Ryan eMVP said:
But wouldn't you have to call a totally different app? I understand doing
it with a library, but I thought the post meant a whole Windows app, so one
exe that could run (Including Forms) on windows or the CF? Totally
different libraries so what would you do once you determined the difference?



Lloyd Dupont said:
very easy !


public static bool IsDevice
{
get { return Environment.OSVersion.Platform == PlatformID.WinCE }
}

public static int NativeFunc()
{
if(IsDevice)
return NativeFuncPPC();
else
return NativeFuncDesk();
}
[DllImport("kernel32.dll", EntryPoint="NativeFunc", SetLastError=true)];
extern static int NativeFuncDesk();
[DllImport("coredll.dll", EntryPoint="NativeFunc, SetLastError=true")];
extern static int NativeFuncPPC();

--
ihookdb
Get your data mobile
http://www.ihookdb.com


William Ryan eMVP said:
How can that be? Wouldn't you have to restrict everything that wasn't
supported on the cf ? I'm intrigued here though, and don't want to
say
it's
not possible if it is. How so?
That is also possible but cumbersome

--
Alex Feinman
---
Visit http://www.opennetcf.org
Floyd:

I see you mentioned a component specifically and you've already found
the
answer. I originally thought you meant create a single exe with forms
that
ran on both. Sorry about the oversight.
I'm just talking about the assembly that contains my component.
Anyway,
I
just went thourhg some of the OpenNetCF source, and they're doing
something
like what I want to do. It seems that you can create a regular C#
ClassLibrary and deploy/run it on a CF device as long as the
..NET
code
is
using stuff that is CF compliant.

--
Floyd Burger


No, you'll need to create a seperate smart device application.
I have a component that works great under Winforms, but I'd like
to
use
it
under CF as well. It's doing a little P/Invoke to use some APIs
that
are
available in WinCE and Windows. What I'd like to do is have a
single
assembly that will run under Winforms and CF so my SmartDevice
application
can run on the PPC and the desktop. Is this possible?
 
W

William Ryan eMVP

Thanks guys, I think I got it now.
Alex Feinman said:
Bill,

Since CF assemblies are retargetable, you can actually compile a basic CF
form application and then launch it on the desktop. The moment you start
using CE-specific stuff, like SqlCE, InputPanel, MessageWindow and CE
P/Invokes, you need to wrap those calls into an extra layer of code to
prevent MissingMethodExceptions

--
Alex Feinman
---
Visit http://www.opennetcf.org
William Ryan eMVP said:
But wouldn't you have to call a totally different app? I understand doing
it with a library, but I thought the post meant a whole Windows app, so one
exe that could run (Including Forms) on windows or the CF? Totally
different libraries so what would you do once you determined the difference?



Lloyd Dupont said:
very easy !


public static bool IsDevice
{
get { return Environment.OSVersion.Platform == PlatformID.WinCE }
}

public static int NativeFunc()
{
if(IsDevice)
return NativeFuncPPC();
else
return NativeFuncDesk();
}
[DllImport("kernel32.dll", EntryPoint="NativeFunc", SetLastError=true)];
extern static int NativeFuncDesk();
[DllImport("coredll.dll", EntryPoint="NativeFunc, SetLastError=true")];
extern static int NativeFuncPPC();

--
ihookdb
Get your data mobile
http://www.ihookdb.com


How can that be? Wouldn't you have to restrict everything that wasn't
supported on the cf ? I'm intrigued here though, and don't want to say
it's
not possible if it is. How so?
That is also possible but cumbersome

--
Alex Feinman
---
Visit http://www.opennetcf.org
Floyd:

I see you mentioned a component specifically and you've already found
the
answer. I originally thought you meant create a single exe with forms
that
ran on both. Sorry about the oversight.
I'm just talking about the assembly that contains my component.
Anyway,
I
just went thourhg some of the OpenNetCF source, and they're doing
something
like what I want to do. It seems that you can create a
regular
C# I'd
like some
APIs
have
 

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