[Mono-devel-list] Using thirdparty lib with mono and linux

Ulrich Meinicke ulrich.meinicke at tepcon.de
Thu Dec 23 10:53:46 EST 2004


I developed a software with mono under Windows XP. It connects to
RFID-reader via Ethernet. Therefore I use a third-party library from the
reader manufacturer. 
Compiling and running with mono just works fine. Also with the .Net
Runtime. But it should also run under linux, but it doesn't.

This is a sample of the code:

using System;
using System.Net;

using ILRnet;
 class PortReader {
	static CiPort3Net  m_refReader = null;
	public static void Main() {

	    if ( m_refReader != null ){
	   	m_refReader = new CiPort3Net();
	   	if (m_refReader.ConnectEthernet("", 7070)){

	   	  Console.WriteLine("Found Reader");
	   	  	Console.WriteLine("Connection to reader failed.

I compile it with: mcs -r:ILRNet.dll file.cs

When I start the program with "mono file.exe" the files ILRNet.dll and
ILR_SDK_DLL.dll must be in the same directory. It's a dll from the
reader manufacturer. My understanding is, that the ILRNet.dll is the
.Net Assembly and this dll calls functions from the ILR_SDK_DLL.dll
library. So the .Net assembly is just a wrapper. 

The reader manufacturer provides a library for linux. I tried to map the
ILR_SDK_DLL.dll  in the config file:
        <dllmap dll="cygwin1.dll" target="libc.so.6" />
        <dllmap dll="libc" target="libc.so.6" />
        <dllmap dll="libintl" target="libc.so.6" />
        <dllmap dll="libxslt.dll" target="libxslt.so" />
        <dllmap dll="libmySQL.dll" target="libmysqlclient.so" />
        <dllmap dll="odbc32.dll" target="libodbc.so" />
        <dllmap dll="oci" target="clntsh" />
        <dllmap dll="db2cli" target="libdb2_36.so"/>
        <dllmap dll="ILR_SDK_DLL.DLL"

As said before compiling this code with mono under linux is just fine. (
I use mono 1.0.4). But during runtime I get the following error:

Unhandled Exception: System.EntryPointNotFoundException: CreateiPort3Obj
in <0x00053> (wrapper managed-to-native)
in <0x0001c> ILRnet.CiPort3Net:.ctor ()
in <0x00047> PortReader:Main ()

Is there anything else I could do that the C (or C++) function and
classes of the reader manufacturer are used. I think the function and
class names are different in the .Net dll and the C++ dll.
But where's the mapping?

I appended the relevant include file from the linux c++ library which
the manufactuerer povides. Any further hints/information would be

Thanks a lot!



// iPortIII.h: interface for the CiPortIII class.

#define AFX_IPORTIII_H__7D35B2D2_B8CB_42E3_AE2F_B3A80EDC1715__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "base_ip3.h"
#include "iTemperatureLog.h"

// socket include for windows
#ifdef WIN32
  #include <winsock.h>
  // link with
  #ifdef _WIN32_WCE
    #pragma comment( lib, "winsock" )
    // tell the compiler to include socket library
    #pragma comment( lib, "Ws2_32" )

#define ILR_SDK_API __declspec(dllexport) #else #ifdef
ILR_SDK_DLL_IMPORTS #define ILR_SDK_API __declspec(dllimport) #else
#define ILR_SDK_API #endif #endif

/// A class to encapsulate the IPort III functionality via a remote
connection class ILR_SDK_API CiPortIII : public CBase_iPortIII { friend
class CiQTag;
	bool Connect(char *szIPAddress, const short sPortNumber);
	virtual bool Disconnect(void);
	virtual ~CiPortIII();
	virtual bool GetInformation(char *szInformation, WORD

	//! \todo Implement me
	virtual bool SetRelays(bool bRelay1, bool bRelay2, bool bRelay3,
bool bRelay4);


	virtual bool ReadTemperatureLog(CiQTag *piQTag, CiTemperatureLog
&iTLog, int nRetries);
	virtual bool StopTemperatureLog(CiQTag *piQTag, int nRetries);
	virtual bool StartTemperatureLog(CiQTag *piQTag, WORD
wIntervalSeconds,int nRetries);
	virtual bool WriteRAM(CBaseTag *pTag, WORD wStartAddress, BYTE
*pbyData, WORD wBytesToWrite, int &iBytesWritten, int retries =
	virtual bool ReadRAM(CBaseTag *pTag, WORD wStartAddress, BYTE
*pbyData, WORD wBytesToRead, int &iBytesRead, int retries =

	virtual bool SessionSetup(CBaseTag* pTag, BYTE byMode, int
retries = -1);
	virtual bool SleepTag(CBaseTag* pTag, BYTE bySeconds, int
retries = -1);
	virtual bool ReadEEPROM(CBaseTag *pTag, WORD wStartAddress, BYTE
*pbyData, WORD wBytesToRead, int &iBytesRead, int retries = -1);
	virtual bool WriteEEPROM(CBaseTag *pTag, WORD wStartAddress,
BYTE *pbyData, WORD wBytesToWrite, int &iBytesWritten, int retries =

	virtual int IPORTWriteConfKey(const char* szKey, int value);
	int  IPORTWriteConfKey(const char* szKey, const char* szValue);
	bool ILRScan(CTagArray &tagArray);
	virtual bool ScanForiDTags(CTagArray &tagArray, WORD
wTagsExpected, BYTE byMaxRollcall, BYTE byMode, int nScanType);
	virtual bool ScanForiQTags(CTagArray &tagArray, WORD
wTagsExpected, BYTE byMaxRollcall, BYTE byMode, int nScanType);
	bool ParseBLINKResponse(CBaseTag* pTag);
	bool ParseWriteEEPROMResponse(CBaseTag *pTag, BYTE *pbyData, int
	bool ParseReadEEPROMResponse(CBaseTag* pTag, BYTE *pbyData, int
	bool ParseScanResponse(CTagArray &tagArray);
	bool ReceiveResponse(char* szRequestCode, unsigned int
	bool ParseReadLogResponse(CiQTag *piQTag, CiTemperatureLog

	void ParseFieldStrengthFromBuffer(CBaseTag* pTag, char*
	void ParseBatteryStatusFromBuffer(CBaseTag *pTag, char
	void ParseVersionFromBuffer(CBaseTag *pTag, char *pBuffer);
	void ParseTemperatureFromBuffer(CBaseTag *pTag, char *pBuffer);

	bool SendCommand(BYTE *pbyBuf, int nBufLen);
	bool IsFullMessageReceived(const int nCurrentLength);
	bool CalculateCRC(BYTE *pbyBuffer, const unsigned int
nBufferLength, char *szResult);

	void SetTime_t(time_t &lTime, int wSecond, int wMinute, int
wHour, int wDay, int wMonth, int wYear);

	SOCKET m_socket;
	char m_cBuffer[1024*8];


#endif //

More information about the Mono-devel-list mailing list