积极答复者
Attempted to read or write protected memory

问题
-
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}
答案
-
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.
- 已建议为答案 Haixia_XieModerator 2014年4月14日 7:57
- 取消建议作为答案 Haixia_XieModerator 2014年4月14日 8:04
- 已标记为答案 yang2013yang 2014年4月15日 11:14
全部回复
-
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.
- 已建议为答案 Haixia_XieModerator 2014年4月14日 7:57
- 取消建议作为答案 Haixia_XieModerator 2014年4月14日 8:04
- 已标记为答案 yang2013yang 2014年4月15日 11:14
-
你好,
如果问题仍然没有解决,请将相对完整的代码贴出来,另外,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.