473,769 Members | 1,959 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 2240
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.co m

"saish" <sa***@eircom.n et> wrote in message
news:11******** *************@g 44g2000cwa.goog legroups.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(MSXML 2::IXMLDOMDocum entPtr pXmlDoc);
extern int WINAPI fnTestInt(int* i);

}
int WINAPI fnTestXml(MSXML 2::IXMLDOMDocum entPtr pXml)
{

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

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

printf("fnTestX mlIn.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("xmlr ef.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
IXMLDOMDocument Ptr. I believe IXMLDOMDocument Ptr 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.co m
"saish" <sa***@eircom.n et> wrote in message
news:11******** *************@g 43g2000cwa.goog legroups.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(MSXML 2::IXMLDOMDocum entPtr pXmlDoc);
extern int WINAPI fnTestInt(int* i);

}
int WINAPI fnTestXml(MSXML 2::IXMLDOMDocum entPtr pXml)
{

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

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

printf("fnTestX mlIn.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("xmlr ef.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
45523
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 defined in "A.html", but every attempt results in an "is not a function" error. I have tried to invoke the function using parent.document.funcname(), top.document.funcname(), and various other identifying methods, but all result in the above...
35
10792
by: hasho | last post by:
Why is "call by address" faster than "call by value"?
1
5354
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" http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/html/vxwlkwalkthroughpassingdatatocustomaction.asp The error I recieve is: "The savedSate dictionary does not contain the expected values and might
22
25602
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 compile. <WebMethod()> _ Public Function VerifySku(ByVal skus As XmlDataDocument) As DataSet Test program : Dim cartSet As DataSet cartSet = ws.VerifySku(cartSet)
12
5342
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 the custom employee class and have built it as a separate library (employee.dll). This employee.dll is being referenced by both the web service and the windows application. I face the following problem when I send this class to the webservice.
2
3992
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 both, one after another. The following error occurs every time I called the second web service: System.Net.WebException was unhandled Message="The underlying connection was closed: A connection that was
0
1823
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 am able to call this method from vb.net desktop client and add a record to the database(this I used to test if there is any problem in the webservice). My main requirement is to create a C++(native dll) wrapper what is recognized by a non...
10
16673
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
2177
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 mcF2ToXml(. . .) As Xml.XmlDocument . . .
0
9579
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10205
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10035
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9984
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7401
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6662
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3949
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 we have to send another system
2
3556
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2811
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.