Call C function from C# problem EntryPointNotFoundException

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hello,

I'v a dll written in C/C++. I only have the header file.
I dont know how to declare the external funtion:
I've got a EntryPointNotFoundException, I think because of the wrong
return type.
The function in the header file return a enum. But I don't know how to
declare it in my c# file.
Can anybody help me?

[DllImport("IHUAPI.dll")]
public static extern int ihuConnect(String server,String
username,String password,ref long serverhandle);

This is the header file:


#define IHUAPI __stdcall

/*
** All possible errors returned by the API functions.
** These do not need to match system API
*/
typedef enum {
ihuSTATUS_OK = 0,
ihuSTATUS_FAILED = 100,
ihuSTATUS_API_TIMEOUT = 101,
ihuSTATUS_NOT_CONNECTED = 102,
ihuSTATUS_INTERFACE_NOT_FOUND = 103,
ihuSTATUS_NOT_SUPPORTED = 104,
ihuSTATUS_DUPLICATE_DATA = 105,
ihuSTATUS_NOT_VALID_USER = 106,
ihuSTATUS_ACCESS_DENIED = 107,
ihuSTATUS_WRITE_IN_FUTURE = 108,
ihuSTATUS_WRITE_ARCH_OFFLINE = 109,
ihuSTATUS_ARCH_READONLY = 110,
ihuSTATUS_WRITE_OUTSIDE_ACTIVE = 111,
ihuSTATUS_WRITE_NO_ARCH_AVAIL = 112,
ihuSTATUS_INVALID_TAGNAME = 113,
ihuSTATUS_LIC_TOO_MANY_TAGS = 114,
ihuSTATUS_LIC_TOO_MANY_USERS = 115,
ihuSTATUS_LIC_INVALID_LIC_DLL = 116,
ihuSTATUS_NO_VALUE = 117,
ihuSTATUS_NOT_LICENSED = 118,
ihuSTATUS_CALC_CIRC_REFERENCE = 119,
ihuSTATUS_DUPLICATE_INTERFACE = 120,
ihuSTATUS_BACKUP_EXCEEDED_SPACE = 121,
ihuSTATUS_INVALID_SERVER_VERSION = 122,
ihuSTATUS_DATA_RETRIEVAL_COUNT_EXCEEDED = 123,
ihuSTATUS_INVALID_PARAMETER = 124,
ihuSTATUS_MAX_ERROR_NUM = 124

} ihuErrorCode;


/* for connecting to one server */
ihuErrorCode IHUAPI ihuConnect
(
char * server,
char * username,
char * password,
long * serverhandle
);
.



Relevant Pages

  • Re: Exported function mangaled name
    ... that header file; it must be declared as __declspec ... You have to declare the function the same way in your .cpp file as in ... #define LIBSPEC __declspec ... See my essay on The Ultimate DLL Header File on my MVP Tips site. ...
    (microsoft.public.vc.mfc)
  • Re: make general windows module
    ... The VB version of these declarations is the "Declare Statement". ... mimicing the behavior of a "windows.h" header file for VB. ... not all Windows API calls can be called from VB as some use reference ...
    (microsoft.public.vb.general.discussion)
  • Re: error: expected ) before * token -- What is this ?
    ... char* helo, char* sender) { ... Does the header file ... declare a type named `SPF_request_t', ...
    (comp.lang.c)
  • Re: confused about extern use
    ... going to achieve by declaring it as extern in the header file a.h. ... composed on one or more compilation units. ... Essentially you *declare* the type wherever it is ...
    (comp.lang.c)
  • Re: Trouble with FILE
    ... reasons I had to split up this program in several modules. ... I can declare, ... extern FILE *fp1; ... included in the header file, so that the FILE type is defined. ...
    (comp.lang.c)