none
Attempted to read or write protected memory RRS feed

  • 问题

  • When I below code:

    using (StreamReader reader = new StreamReader(res.Stream))

    the below exception appears!

    +  $exception {System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.} System.Exception {System.AccessViolationException}

    2014年4月10日 15:27

答案

  • In my opintion,when you construct a  StreamReader you should give it the file path. In your code, you give it res.Stream. It  is memory stream, I don't think you can do like this. You can attempt to use reader.Read(res.Stream).

     Just suggestion. Thanks.

    2014年4月11日 6:00

全部回复

  • In my opintion,when you construct a  StreamReader you should give it the file path. In your code, you give it res.Stream. It  is memory stream, I don't think you can do like this. You can attempt to use reader.Read(res.Stream).

     Just suggestion. Thanks.

    2014年4月11日 6:00
  • 你好,

    如果问题仍然没有解决,请将相对完整的代码贴出来,另外,MSDN上有StreamReader类的介绍以及各种构造函数的使用方法,可作为参考。

    http://msdn.microsoft.com/zh-cn/library/system.io.streamreader(v=vs.110).aspx


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2014年4月14日 8:13
    版主