Problem with : "Acces Navision Stream From DotNet"

f.ritz
Member Posts: 13
I would like to read a Stream from .NET in Navision, in order to use this for a XMLPort. But the Instream is after Rec.MODIFY empty in Navision.
I uses this project here:
http://www.mibuso.com/dlinfo.asp?FileID=776
C#:
Navision:
What can I make otherwise?
I uses this project here:
http://www.mibuso.com/dlinfo.asp?FileID=776
C#:
public bool SendToNavision([Out, MarshalAs(UnmanagedType.AsAny)] object COMStream, string fileName) { IStream COMStream1 = COMStream as IStream; this.rwBytes = Marshal.AllocHGlobal(4); int bytes = 0; byte[] buffer1 = new byte[0xafc8]; FileStream reader = new FileStream(fileName, FileMode.Open); //IStream COMStream = new IStream(); int _rwBytes = 0xafc8; bool result = true; int bytesRead = 0; do { bytesRead = reader.Read(buffer1, 0, _rwBytes); Marshal.WriteInt32(this.rwBytes, bytesRead); COMStream1.Write(buffer1, bytesRead, this.rwBytes); } while (bytesRead > 0); //COMStream1.Commit(0); reader.Close(); reader.Dispose(); Marshal.FreeHGlobal(this.rwBytes); return result; }
Navision:
Rec.INIT; Rec.INSERT; Rec.BlobData.CREATEINSTREAM(InStr); CREATE(StreamTest); RetVal :=StreamTest.SendToNavision(InStr,'C:\toNAV.xml'); Rec.MODIFY; XMLPORT.IMPORT(80003, InStr); //The InStr is now empty!!!!!!!!!
What can I make otherwise?
0
Comments
-
I managed once to implement the "NAV compatible" Stream in .Net, and what I remember is that I just passed one of the COM Stream interfaces to NAV as an object and cast it, very similar as the InMessage needs to be casted in the ComCom event.
In C#, you "just" need to implement the interface and call the underlaying .Net stream, which means really a wrapper call to all methods, which are usually one line of code each. As far as I remember, you just need to wrap the READ and WRITE and maybe make the wrapper object IDisposable.
I can try to look for the code if needed.
Regards,_________________
“This posting is provided "AS IS" with no warranties, and confers no rights.”0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions