472,992 Members | 3,084 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

dll call by passing XMLDocument by reference

Hello

Need your help, I have a C++ win32 dll which takes xml document type by
reference. I need to call this dll from c# .net.
I tried using DllImport, but dll funtion when call does not respond.
I tried calling similar dll for a function which take integer by
refernce. It works ok in this case.

Please can you let me know if we can call a c++ win32 dll function by
passing a xmldocument by reference?

Thanks
saish

Jan 10 '06 #1
4 2205
saish,

I can't imagine that it uses the .NET implementation of an XML document.

What is the type of the reference? You need to make sure you are
passing the correct type to the function.

What is the declaration in the header file for the function?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"saish" <sa***@eircom.net> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
Hello

Need your help, I have a C++ win32 dll which takes xml document type by
reference. I need to call this dll from c# .net.
I tried using DllImport, but dll funtion when call does not respond.
I tried calling similar dll for a function which take integer by
refernce. It works ok in this case.

Please can you let me know if we can call a c++ win32 dll function by
passing a xmldocument by reference?

Thanks
saish

Jan 10 '06 #2
Hi Nicholas,

Thanks for your reply ..sorry for not being clear ..

details below ..

I have a C++ win 32 dll which as below code. It has two function one
which takes integer by reference and one with xmldocument by reference.
These dll functiona are called successfully by a C++ executables.
----------------
extern "C"
{
extern int WINAPI fnTestXml(MSXML2::IXMLDOMDocumentPtr pXmlDoc);
extern int WINAPI fnTestInt(int* i);

}
int WINAPI fnTestXml(MSXML2::IXMLDOMDocumentPtr pXml)
{

printf("fnTestXmlIn.pXml.xml=\n%s\n", (LPCSTR)pXml->xml);

pXml->loadXML("<root><adddednode>By the dll</ adddednode ></root>");

printf("fnTestXmlIn.pXml.xml=\n%s\n", (LPCSTR)pXml->xml);

return 99;
}

int WINAPI fnTestInt(int & px)
{
px = px + 10;

return 122;

}

LIBRARY xmlref
EXPORTS
FUNC_XML = fnTestXml
FUNC_INT = fnTestInt

-------------------

I have a requirement where one of our web services which recevies
xmldocument written either in vb.net or csharp has to call these dll
functions and pass these xmldocument.

csharp test code
----------------------
[DllImport("xmlref.dll")]
public static extern int FUNC_XML(ref XmlDocument pdoc);
....
XmlDocument xmlin = new XmlDocument();
xmlin.LoadXml("<test> how r u </test>");
FUNC_XML(ref xmlin); <----- It fails here ..
---------

The above dll code is a test code. the actual dll is one of calculation
dll engines which takes xmldocument by reference. This dll is called by
many application. One of my requirement was to call this dll from a
..net web service.

Thanks

Jan 10 '06 #3
saish,

The XmlDocument in .NET and the implementation of the IXMLDOMDocument is
not the same. You can not interchange the two.

First, you should expose the IXMLDOMDocument interface, not the
IXMLDOMDocumentPtr. I believe IXMLDOMDocumentPtr is a wrapper that is
generated for you which helps with the management of the instance.

Then, you have to set a reference to MSXML.dll in your .NET project, and
use the XML classes from there in order to pass to your dll.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"saish" <sa***@eircom.net> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
Hi Nicholas,

Thanks for your reply ..sorry for not being clear ..

details below ..

I have a C++ win 32 dll which as below code. It has two function one
which takes integer by reference and one with xmldocument by reference.
These dll functiona are called successfully by a C++ executables.
----------------
extern "C"
{
extern int WINAPI fnTestXml(MSXML2::IXMLDOMDocumentPtr pXmlDoc);
extern int WINAPI fnTestInt(int* i);

}
int WINAPI fnTestXml(MSXML2::IXMLDOMDocumentPtr pXml)
{

printf("fnTestXmlIn.pXml.xml=\n%s\n", (LPCSTR)pXml->xml);

pXml->loadXML("<root><adddednode>By the dll</ adddednode ></root>");

printf("fnTestXmlIn.pXml.xml=\n%s\n", (LPCSTR)pXml->xml);

return 99;
}

int WINAPI fnTestInt(int & px)
{
px = px + 10;

return 122;

}

LIBRARY xmlref
EXPORTS
FUNC_XML = fnTestXml
FUNC_INT = fnTestInt

-------------------

I have a requirement where one of our web services which recevies
xmldocument written either in vb.net or csharp has to call these dll
functions and pass these xmldocument.

csharp test code
----------------------
[DllImport("xmlref.dll")]
public static extern int FUNC_XML(ref XmlDocument pdoc);
...
XmlDocument xmlin = new XmlDocument();
xmlin.LoadXml("<test> how r u </test>");
FUNC_XML(ref xmlin); <----- It fails here ..
---------

The above dll code is a test code. the actual dll is one of calculation
dll engines which takes xmldocument by reference. This dll is called by
many application. One of my requirement was to call this dll from a
.net web service.

Thanks

Jan 10 '06 #4
Nicholas:
I took your lead and was able to add reference of MSXML2 to .net and
was able to pass byval DOMDOCUMENT from .net to my dll.
Since the dOM document going to be a huge data, we were prefering to
pass byref. But we were not able to pass byref, but atleast we are able
to get this far. Thanks for your help.
Saish.

Jan 19 '06 #5

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

Similar topics

26
by: Dave Hammond | last post by:
In document "A.html" I have defined a function and within the document body have included an IFRAME element who's source is document "B.html". In document "B.html" I am trying to call the function...
35
by: hasho | last post by:
Why is "call by address" faster than "call by value"?
1
by: Hans [DiaGraphIT] | last post by:
Hi! I have problem with passing data to custom action. I don't know what wrong I'm doing. I'm trying to follow the steps in the walkthrough: "Passing Data to a Custom Action" ...
22
by: Arne | last post by:
How do I pass a dataset to a webservices? I need to submit a shoppingcart from a pocket PC to a webservice. What is the right datatype? II have tried dataset as a datatype, but I can't get it to...
12
by: Noel | last post by:
Hello, I'm currently developing a web service that retrieves data from an employee table. I would like to send and retrieve a custom employee class to/from the webservice. I have currently coded...
2
by: Lorenzo | last post by:
I have a .net webservice (located in a different machine) that is called twice from a windows form .net application. The ws works fine if I called only one call, but failed if I called them...
0
by: Sathya | last post by:
Hi, I have a vb.net webservice which takes XMLDocument as a parameter and returns bool. Signature of the method is some thing like this AddXmlEmpDetails(xmlEmp as XMLDocument) as Boolean. I...
10
by: ravi | last post by:
Hi, i am a c++ programmer, now i want to learn programming in c also. so can anybody explain me the difference b/w call by reference and call by pointer (with example if possible).
10
by: Atara | last post by:
Suppose I have the following functions: Public Function myF1ToStream(...) As System.IO.MemoryStream . . . Dim ms As New System.IO.MemoryStream(buf) Return ms End Function Public Function...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.