Passing MemoryStream ByRef Issue

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jason Taylor

    Passing MemoryStream ByRef Issue

    Hello,

    I have created a Web service with the following web method;

    <WebMethod()> _
    Public Function HelloWorld(ByVa l myMemoryStream As
    System.IO.Memor yStream) As String
    Return "Hello World"
    End Function

    I have also created a Web application with the following subroutine;

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArg s) Handles MyBase.Load
    Dim mySample As New localhost.Sampl e
    Response.Write( mySample.HelloW orld(Response.O utputStream))
    End Sub

    Line 2 of the Page_Load sub generates the error; Value of type
    'System.IO.Stre am' cannot be converted to
    'Sample_Debug.l ocalhost.Memory Stream'.

    What should I do to fix this?

    Thanks,

    Jason.
  • Keenan Newton

    #2
    Re: Passing MemoryStream ByRef Issue

    Well to the best of my knowledge you can not pass a memory stream. i
    won't serialize on its own, so I think web serivces will have issues
    with it, but you can convert the memory stream to a byte array with the
    ToArray method pass that through the web service, and then put it back
    into a memorystream (one of the constructor overloads accepts a byte
    array). However i have to be honest I am not sure if trying to move
    memory stream acros a web service is wise in the first place. But then
    again I don't know what you are trying to accomplish

    Comment

    • Jason Taylor

      #3
      Re: Passing MemoryStream ByRef Issue

      Thanks Keenan, have taken an alternate solution.

      Cheers,

      Jason

      Comment

      • Richard

        #4
        Re: Passing MemoryStream ByRef Issue

        Could please tell me what alternative method you are using?

        "Jason Taylor" wrote:
        [color=blue]
        > Thanks Keenan, have taken an alternate solution.
        >
        > Cheers,
        >
        > Jason[/color]

        Comment

        • Richard

          #5
          Re: Passing MemoryStream ByRef Issue

          Could please tell me what alternative method you are using?

          "Jason Taylor" wrote:
          [color=blue]
          > Thanks Keenan, have taken an alternate solution.
          >
          > Cheers,
          >
          > Jason[/color]

          Comment

          Working...