1 Replies - 781 Views - Last Post: 08 May 2013 - 11:02 AM Rate Topic: -----

#1 tieties  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 08-October 12

NullRefrenece error

Posted 08 May 2013 - 02:06 AM

HI so i get a nullreference error at line 31, but i do get a warning at line 15("ResultStream")with a green line which says the variable is used before it is assigned a value.
Sometimes it works and sometimes it doesnt so im clue less now can anybody tell me for what i must look at please

            Try
                ResultStream = rs.Render(format, devInfo, extension, encoding, mimeType, warnings, streamIDs)

                execInfo = rs.GetExecutionInfo()

                Console.WriteLine("Execution date and time: {0}", execInfo.ExecutionDateTime)

            Catch err As SoapException
                'Console.WriteLine(e.Detail.OuterXml)
            End Try

            Try
                Dim stream As FileStream = File.Create(FilePath + Session("LetterTitle") + ".pdf", ResultStream.Length)
                Console.WriteLine("File created.")
                stream.Write(ResultStream, 0, ResultStream.Length)
                Console.WriteLine("Result written to the file.")
                stream.Close()
            Catch err As System.Exception
                Console.WriteLine(err.Message)
            End Try

            Response.Clear()
            Response.ContentType = "application/octet-stream"
            Response.AddHeader("Content-Type", contentType)
            Response.AddHeader("Content-Disposition", "attachment;filename=BrokerAppintmentLetter(" + Session("klientId").ToString + ").pdf")
            Response.BinaryWrite(ResultStream)
            Response.Flush()
            Response.End()

        


Is This A Good Question/Topic? 0
  • +

Replies To: NullRefrenece error

#2 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1043
  • View blog
  • Posts: 4,057
  • Joined: 02-July 08

Re: NullRefrenece error

Posted 08 May 2013 - 11:02 AM

You say lines 31 and 15. Are the lines for your code or the code block in the post. Please clarify, cause 31 does not exist here. You should check Session variables before using them - it may be null.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1