Calling XmlInterop.dll jdeXmlRequest from Microsoft .NET C#

Mathijs

Member
Hi,

I am using the function jdeXmlRequest in xmlinterop.dll to send and recieve message to and from JDE.

I call the xmlinterop.dll function from C# using DLLImport ( code below )

However, after about 5 succesfull calls, the .NET app seems to crash and only returns the follwing error:

Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

After some extensive googling I found that this error is most likely caused by Marshaling the wrong types.

My problem is do not have the header file for xmlinterop.dll and therefor do not exactly know what the correct types are.

Can somebody show me the orignal method signature?
Or even better, the correct DLLImport for this function?

By the way, I only recieve this error when using the proxy class in my web app. If i use it in a winforms app. Everything works smoothly

My Proxy class code:
--------------------------

public class JdeProxy
{
[DllImport("xmlinterop.dll", EntryPoint = "_jdeXMLRequest@20")]
protected static extern string JdeXMLRequest(string server, int port, int timeout, string xml, int x);

private string serverNameOrIp;
private int port;
private int timeout;

public JdeProxy(string serverNameOrIp, int port)
: this(serverNameOrIp, port, 10)
{

}

public JdeProxy(string serverNameOrIp, int port, int timeout)
{
this.serverNameOrIp = serverNameOrIp;
this.port = port;
this.timeout = timeout;
}

public string Request(string xml)
{

return JdeXMLRequest(
serverNameOrIp,
port,
timeout,
xml,0);
}
}
 
No one?
frown.gif
 
I have used this and it seems to work

using System;
using System.Runtime.InteropServices; // DllImport

namespace NET_EXAMPLE
{
/// <summary>
/// Summary description for Class2.
/// </summary>
public class Jde_XML
{
public Jde_XML()
{
//
// TODO: Add constructor logic here
//
}
[DllImport("c:\\\dll\\xmlinterop.dll ")]
public static extern IntPtr jdeXMLRequest(
String szHostName,
UInt16 lPort,
Int32 lTimeout,
String XML_Msg_IN,
Int32 lSize);

}
}
 
Back
Top