473,406 Members | 2,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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 1288

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

Similar topics

5
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
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
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
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
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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
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...

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.