System.AccessViolationException:尝试读取或写入受保护的内存(System.AccessViolationException: Attempted to read or

编程入门 行业动态 更新时间:2024-10-27 13:30:46
System.AccessViolationException:尝试读取或写入受保护的内存(System.AccessViolationException: Attempted to read or write protected memory)

我尝试从我的服务器中的Excel文件读取时收到以下错误。

“System.AccessViolationException:尝试读取或写入受保护的内存。这通常表示其他内存已损坏。”

代码在localhost中运行顺利,但是当我在线托管它时会出现错误。

我无法发布堆栈跟踪,因为我没有每次都得到错误,但执行停止在“objConn.open”行 。 该页面只是说加载......没有任何反应。

这是我的代码块:

fuGroupAttributes.SaveAs(IO.Path.Combine(Server.MapPath("~/Admin/SpecificationExcels"), lblParentId.Text.Trim & IO.Path.GetExtension(fuGroupAttributes.FileName))) 'saving the excel file from the fileUploader Dim path As String = Server.MapPath("~/Admin/SpecificationExcels/" & lblParentId.Text.Trim & IO.Path.GetExtension(fuGroupAttributes.FileName)) 'getting the file path from the server Dim connectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & path & ";Extended Properties=Excel 12.0;" Dim objConn As New OleDbConnection(connectionString) **objConn.Open()** 'this is where i am getting the error. Dim strConString As String = "SELECT * FROM [Sheet1$]"

编辑:页面一直在说加载...它不会停止加载...

I am getting the following error while trying to read from an excel file in my server.

"System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

The code runs smoothly in localhost, but the error comes when i host it online.

I am unable to post the stacktrace as i do not get error everytime, but the executions stops at the line "objConn.open". The page just says loading... and nothing happens.

Here is my code block :

fuGroupAttributes.SaveAs(IO.Path.Combine(Server.MapPath("~/Admin/SpecificationExcels"), lblParentId.Text.Trim & IO.Path.GetExtension(fuGroupAttributes.FileName))) 'saving the excel file from the fileUploader Dim path As String = Server.MapPath("~/Admin/SpecificationExcels/" & lblParentId.Text.Trim & IO.Path.GetExtension(fuGroupAttributes.FileName)) 'getting the file path from the server Dim connectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & path & ";Extended Properties=Excel 12.0;" Dim objConn As New OleDbConnection(connectionString) **objConn.Open()** 'this is where i am getting the error. Dim strConString As String = "SELECT * FROM [Sheet1$]"

EDIT : The page keeps saying loading ... it wont stop loading...

最满意答案

最可能的原因是,您的计算机上的用户帐户没有足够的权限来执行此操作。 在localhost上,您可能正在使用管理员帐户,而在实时计算机中则不是这样。

Most probable reason is, your user account on the machine does not have sufficient access to perform this operation. On localhost, you might be using the Administrator account and it is not so in the live machine.

更多推荐

本文发布于:2023-08-01 03:53:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1352781.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:内存   Attempted   System   AccessViolationException   protected

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!