473,503 Members | 2,059 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ODM API calls from C# .NET

Really need some help with a problem that is bugging me.

I am trying to wrtie a C#.NET wrapper for the ODM (Open Document
Management)
API. I have written wrapping classes for other Windows API's in the
past in
VB6 and have not had a problem. However, VB6 is not a 'strictly typed'
language, and I think it is the type conversions from C# to the ODM
API that
is cauing my problem.

The following is an extract from the "ODMA.h" file that contains the
definitions of the ODM API

//----------------------------------------------------
ODMSTATUS WINAPI ODMSaveAsEx(ODMHANDLE odmHandle, LPSTR lpszDocId,
LPSTR lpszNewDocId, LPSTR lpszFormat, ODMSAVEASCALLBACK pcbCallBack,
LPVOID pInstanceData, LPDWORD pdwFlags);
//----------------------------------------------------

The following is my declaration in C# of this API function

//----------------------------------------------------
[DllImport("ODMA32.DLL", EntryPoint="ODMSaveAsEx")]
internal static extern Int16 ODMSaveAsEx
(
Int32 odmHandle,
string lpszDocId,
StringBuilder lpszNewDocId,
string lpszFormat,
Int32 pcbCallBack,
Int32 pInstanceData,
ref Int32 pdwFlags
);
//----------------------------------------------------

I am calling the API function via my declaration using the following
code

//----------------------------------------------------
/*
THESE 3 VARIABLES ARE ALREADY SET FROM PREVIOUS
CALLS TO OTHER ODM API METHODS
Int32 lngSessionID = //<The current session ID>//
string strDocID = //<The current document ID>//
string strDocumentFormat = //<The current docuemtn format>//
*/
Int16 intSuccess;
Int32 intCallBack = 0;
Int32 intInstanceData = 0;
Int32 intFlags = 0;
StringBuilder strBuffer = new StringBuilder(255);

intSuccess = ODMSaveAsEx (lngSessionID, strDocID,
strBuffer, strDocumentFormat, intCallBack,
intInstanceData, ref intFlags);
//----------------------------------------------------

When I run this call to "ODMSaveAsEx" I get the following error.

//----------------------------------------------------
An unhandled exception of type
'System.NullReferenceException' occurred in odmadocmanager.dll

Additional information:
Object reference not set to an instance of an object.
//----------------------------------------------------

Now I know what it looks like. I looks like I am passing a NULL
refernece to
this API call. This is not the case. I am absolutely sure that this
problem is
related to type compatability.

* Does anyone know of any specific Type conversion problems when
calling API's from C#?
* Has anyone ever done any development on the ODM API with .NET?

I know that you have to watch out for the following...

LONG (API world) = Int32 (.NET world)
INT (API world) = Int16 (.NET world)

....and I have tried to ensure that the correct type is used in my C#
code.
However, I am still stuck on this.
Can anyone help?

Much appreciated!!!
Cluggas
Nov 16 '05 #1
0 1298

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3507
by: markus | last post by:
Hi, I have a question that deals with the standard c library VS (Unix) system calls. The question is: which header files (and functions) are part of the C library and which header files (and...
6
2106
by: A.M-SG | last post by:
Hi, We are developing a SmartClient application and we are planning to expose business objects layer to SmartClient application by using ASP.NET SOAP web services.
10
2613
by: Brian Parker | last post by:
I inherited a C++ DLL that I need to remotely call multiple times asynchronously. What I have developed is: CSharp web application that makes asynchronous calls to a CSharp Web Service. The...
21
2426
by: omkar pangarkar | last post by:
Hi all, I have two simple hello world programs one using printf() and other using write() --prog 1-- #include<stdio.h> #include<stdlib.h> int main() { printf("Hello"); /* up to here...
1
1960
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi... There are a few questions wrapped up in this, but the main one is that the WebService.MyMethodAsync() methods that are automatically generated in the client code by VS 2005 don't seem to...
0
7091
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7282
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7464
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5586
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5018
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3171
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3162
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1516
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
741
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.