Problem with : "Acces Navision Stream From DotNet"

f.ritzf.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#:
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?

Comments

  • jorgecphjorgecph Member Posts: 26
    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.”
Sign In or Register to comment.