using C# class as COM component in Pocket PC and Smartphone 2003

C

Chang Kuang

Gurus,

I am almost out of resources (and hair) in figuring out using C# class
as COM component in Pocket PC and Smartphone 2003. Basically I need to
implement a pre-defined C++ interface in Embedded VC++. Part of the
implementation, I hope, can make use of nice C# classes available in
..NET compact framework, and C# classes that I developed under my own
namespace using Visual Studio .NET 2003.

Well this is not an unexplored territory in desktop environment.
However, in Pocket PC world, it still seems a daunting task. Below is a
summary of what I found:

1. Using managed C++ to mix C++ and C# in source code level.
No go in pocket pc as Visual Studio .NET 2003 does not have such a
choice for so-called smart device.

2. Prefix a C# interface and its implementation C# class using
Guid/InterfaceType/ClassInterface attributes, register them using
regasm.exe to expose them as a COM component that will be taken care by
mscoree.dll.
No go in pocket pc as InterfaceType/ClassInterface attributes are not
supported in .NET Compact Framework.
However, Visual Studio .NET indeed builds a .tlb file. Anybody
successfully makes use of this .tlb file by directly importing it in C++
source code?

3. Directly host .NET runtime by creating coclass CLSID_CorRuntimeHost
instance, starting up the runtime, getting default domain, and creating
an instance of the C# class.
Did not test in PPC environment yet.

4. Using some commercial enablers? I doubt my company would approve that.

Appreciate any pointers, except that (1) using C++ then; (2) waiting for
MS next release of .NET CF.

- Chang
 
P

Paul G. Tobey [eMVP]

You'd be better off taking the C# class and porting it to C++ to implement
the COM stuff. There's currently no COM support in the .NET CF, certainly
none for using managed code as a COM object.

1. You can't use managed C++. It is not supported in .NET CF.

Paul T.
 
C

Chris Tacke, eMVP

- You can't use managed C++ in the CF (won't be in 2.0 either).
- You cannot host the CF CLR in unmanaged code (will be available in 2.0)
- The CF doesn't support COM at all, so it cannot create COM objects. (this
may be in 2.0)
 

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