Use Stream in .NET 2005

Anything related to Barcode ActiveX programming

Use Stream in .NET 2005

Postby teissier(legacy member) on Sun Jan 15, 2006 6:37 am

Hi all,

I'm coding in .NET 2005.

I have some problem by using the method "ExportImage" with the

Stream objet. I have used a MemoryStream in my code by the method "ExportImage" throw a exception.

Somebody can tell me how to use properly the method "ExportImage" in a Stream objet ?

Thank you very much,

Yves Teissier.
teissier(legacy member)
 

Re: Use Stream in .NET 2005

Postby glitch (legacy member) on Mon Jan 16, 2006 9:29 am

The .Net class MemoryStream does not provide IStream interface. Consequently the ExportImage does not accept it as a parameter.

We use ADODB.Stream object because it provides a standard IStream interface. In theory the ExportImage can take any Stream object. If you are programming in C++, you may refer to http://www.morovia.com/support/article.aspx?id=10027.

The ADODB.Stream.Open takes 5 optional parameters. You can use the follwing statement

Stream.Open(Type.Missing, (ConnectModeEnum)0, (StreamOpenOptionsEnum)0xffffffff, "", "" );

For more information about passing optional parameter in C#, see kb article http://support.microsoft.com/?kbid=305814.

The most convenient way is to use in a scripting language such as VBScript. The V3.2 comes with an IIS sample written in VBScript:

' The Stream object is available in MDAC 2.5 and above versions. You can download the most
' recent MDAC at http://www.microsoft.com/data/mdac/
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary

' Export the Image to Stream object.
' After transfer completes, the Position must set to 0 before Calling Response.BinaryWrite
' otherwise an "unknown type" is reported.
objBarcode.ExportImage objStream, 1
objStream.Position = 0

' BinaryWrite the image data to the client browser
Response.BinaryWrite objStream.Read
glitch (legacy member)
 


Return to Barcode ActiveX Control

Who is online

Users browsing this forum: No registered users and 0 guests