serializing is not possible within the available system classes of .NET CF. I guess i need to operate with unsafe code, what do u think?
First I wanted to use wrapping instead of rewriting the code, Did u made some experiences already with this?
please find attached post
Thanks a lot again,
stonee
--------------------------------------------------------
I need to use an existing Programming Interface which is available whether as a 'COM object dll' or' 2 C++ header files' under .NET.
I used the COM object, this works quite nice inVB.NET as well in C#, using the System.Runtime.InteropServices.TypeLibConverter class.
In fact everything will be done automatically and i can use my Interface like in the unmanaged world, great!
The main problem is will develop an application on a PocketPC, under the .NET Compact Framwork.
Since this System.Runtime.InteropServices.TypeLibConverter class does not exist under the NET CF, i need to use the C++ interface, but this gives me headache.
So far I found out the following:
To use (unmanaged) C++ Code in the managed world of .NET, there are several possibilities.
You can use the built-in .NET runtime interop facilities to talk directly to the existing code.
You can wrap the code using the managed extensions to C++.
You can rewrite the code in a .NET language.
I wanted to go in direction step 3, but I'm no longer sure what makes really sense on this one....
My interface is consisting of 3 header files. 2 of them are simply describing enumerations and structs.
The third one consists of helper classes in C++ which are easing the use of this interface a lot.
I assume that when I would go the wrapping way, that I would only need to wrap the classes I directly touch from my App in c#?
If yes then I woud need to wrap only 2 classes:
But how would I do that best? Could somebody give me an idea how to do that?
Thanks a lot,
stonee
Attached the sample classes:
//sender.h
Class1 to wrap:
// Macro to compact duplicate code
#define DATA_PACKET &Data.DataPacket, sizeof(Data.DataPacket)
class Command
{
public:
CESAPICommand() {TRACE(_T("CESAPICommand()\n"

);}
virtual bool SendPacket(void* PacketStart, long PacketSize)
{
TRACE(_T("Virtual SendPacket() called!\n"

);
return false;
};
// Send commands
bool inline Init() {CInit Data; return SendPacket(DATA_PACKET);}
bool inline SetBox(double dX1, double dY1, double dZ1, double dX2, double dY2, double dZ2)
{CSetBox Data(dX1, dY1, dZ1, dX2, dY2, dZ2); return SendPacket(DATA_PACKET);}
};
Class2 to wrap:
///Receiver.h
class Receive
{
public:
Receive() {TRACE(_T("Receive()\n"

);}
protected:
bool ReceiveData(void* packetStart, long packetSize)
{
if (packetStart && packetSize > 0)
return ProcessData(packetStart, packetSize);
else
return false;
};
protected:
virtual void OnInitializeAnswer() {TRACE(_T("virtual OnInitializeAnswer() call\n"

);}
virtual void OnGetBoxAnswer(const BoxRegionDataT& boxRegionData) {TRACE(_T("virtual OnGetBoxRegionParamsAnswer() call\n"

);}
protected:
// It is supposed that one and only one and COMPLETE data
// packet is being passed to this function.
// Parameter 'lBytes' just passed for diagnostics purpose
//
virtual bool ProcessData(void *pDataArrived, long lBytes)
{
PacketHeaderT *pData = (PacketHeaderT*)pDataArrived;
// Diagnostics and overflow prevention.
if (pData->lPacketSize != lBytes)
{
TRACE2("PacketSize (%ld) differs from TotalBytes (%ld) !\n", pData->lPacketSize, lBytes);
return false; // causes to signal a data receive error
} // if
switch (pData->type)
{
case ES_DT_Command: // A 'command- type' answer has arrived
{
// call general virtual function for commands
//
OnCommandAnswer(*(BasicCommandRT *)pData); // uses reference parameter. see comment in header file
// decode type of command
BasicCommandRT *pData2 = (BasicCommandRT *)pData;
// handle error
if (pData2->status != ES_RS_AllOK)
return true; // Exit here, but make sure pData2->status gets forwared somehow.
// This is done on using the general OnCommandAnswer() function above.
switch (pData2->command)
{
case ES_C_ExitApplication:
OnExitApplicationAnswer();
break;
case ES_C_GetSystemStatus:
OnGetSystemStatusAnswer(((GetSystemStatusRT*)pDataArrived)->lastResultStatus,
((GetSystemStatusRT*)pDataArrived)->trackerProcessorStatus,
((GetSystemStatusRT*)pDataArrived)->laserStatus,
((GetSystemStatusRT*)pDataArrived)->admStatus,
((GetSystemStatusRT*)pDataArrived)->esVersionNumber,
((GetSystemStatusRT*)pDataArrived)->weatherMonitorStatus,
((GetSystemStatusRT*)pDataArrived)->lFlagsValue,
((GetSystemStatusRT*)pDataArrived)->lTrackerSerialNumber);
break;
case Init
OnInitializeAnswer();
break;
case ES_C_GetReflectors:
OnGetReflectorsAnswer(((GetReflectorsRT*)pDataArrived)->iTotalReflectors,
((GetReflectorsRT*)pDataArrived)->iInternalReflectorId,
((GetReflectorsRT*)pDataArrived)->targetType,
((GetReflectorsRT*)pDataArrived)->dSurfaceOffset,
((GetReflectorsRT*)pDataArrived)->cReflectorName);
break;
// Do not treat unknown packets as error - just ignore them
TRACE(_T("Unexpected data received (ignored)\n"

);
break;
} // switch
return true;
} // ProcessData()
};