StreamResource Error (.NET 3.5)

CraigMuckleston

New member
Joined
Aug 3, 2008
Messages
1
Programming Experience
3-5
I have the following bit of code:
VB.NET:
Private Sub TestLoader_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)

    DownloadObjectPart("images.zip")
End Sub

Private Sub DownloadObjectPart(ByVal objPart As String)
    Dim wc As New WebClient
    AddHandler wc.OpenReadCompleted, AddressOf wc_OpenReadCompleted
    AddHandler wc.DownloadProgressChanged, AddressOf wc_DownloadProgressChanged
    wc.OpenReadAsync(New Uri("images.zip", UriKind.Relative), objPart)

End Sub

Private Sub wc_OpenReadCompleted(ByVal sender As Object, ByVal e As OpenReadCompletedEventArgs)

    Dim sri As New StreamResourceInfo(TryCast(e.Result, Stream), Nothing)
    Dim sURI As String = TryCast(e.UserState, String)
    Dim imageStream As StreamResourceInfo = Application.GetResourceStream(sri, New Uri(sURI, UriKind.Relative))
    Dim imgsrc As New BitmapImage
    imgsrc.SetSource(imageStream.Stream)
    ImgToFill.Source = imgsrc
End Sub

When I run the code I get the error:
ArgumentNulException
Value cannot be null. Parameter name: The stream parameter value cannot be null
on the line:Dim sri As New StreamResourceInfo(TryCast(e.Result, Stream), Nothing)

Any ideas?
 
Back
Top