473,511 Members | 16,730 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2228
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
45471
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
10740
by: hasho | last post by:
Why is "call by address" faster than "call by value"?
1
5345
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
25549
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
5293
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
3978
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
1812
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
16646
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
2135
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
7355
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,...
1
7081
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7510
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
5668
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,...
0
4737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3225
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
1576
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
781
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
447
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.