I've received an unmanaged DLL file from a client. This DLL file has an important method that returns an XML stream. I am not sure how to 'catch' this XML stream because the DLL file is pretty much undocumented. This is what I know:
OpenXmlBridge
This is where I am stuck at right now:
[DllImport("UnmanagedDllFile.DLL")]
public static extern void OpenXmlBridge();
I know that this returns void
when executed but I am at a loss right here. I also know that this function exeists because when I replace OpenXmlBridge
with some random stuff, I get errors. So until now, I guess I've been on the right track. I haven't been able to find out what to do exactly from here.
I anyone could be able to point me into the right direction so I can retrieve the XML stream handle from this function. Any help or tips are greatly appreciated.
You can use UnmanagedMemoryStream
class. In that case your wrapper whould look like:
[DllImport("UnmanagedDllFile.DLL")]
public static extern IntPtr OpenXmlBridge();
And the code to access it would be something like:
var length = 0 //stream length here
var pointer = NativeWrapper.OpenXmlBridge();
using(var ms = new UnmanagedMemoryStream((Byte*)pointer, length){
var xDocument = new XmlDocument();
xDocument.Load(ms);
//process document
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.