代码功能就是将CSV文件数据导入到ACCESS数据库里。
在调试过程中运行一次不会报错,但是连续运行多次就出错(次数不定,有时3次有时5次)
运行到 OleDbConnection.open() 时会报错“尝试读取或写入受保护的内存。这通常指示其他内存已损坏。”
网上查过一些类似问题,说是改目标平台为“Anycpu”能解决,但是亲测失败(倒是比X86能多运行几次。。。)
环境 win7 32位,vs2010,framework 4.5 版本
本人初学者,希望大神们解释的尽量通俗点。谢谢
错误描述如下:
未处理 System.AccessViolationException
HResult=-2147467261
Message=尝试读取或写入受保护的内存。这通常指示其他内存已损坏。
Source=System.Data
StackTrace:
在 System.Data.OleDb.DataSourceWrapper.InitializeAndCreateSession(OleDbConnectionString constr, SessionWrapper& sessionWrapper)
在 System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)
在 System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
在 System.Data.ProviderBase.DbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
在 System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
在 System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
在 System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
在 System.Data.ProviderBase.DbConnectionInternal.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
在 System.Data.OleDb.OleDbConnection.Open()
在 GXCTV1.FMWTK.insClk(String CLkPathNam) 位置 C:\Users\Administrator.SKY-20170415EAI\Documents\Visual Studio 2010\Projects\GXCTV1\GXCTV1\FMWTK.cs:行号 866
在 GXCTV1.FMWTK.insWtk_Click(Object sender, EventArgs e) 位置 C:\Users\Administrator.SKY-20170415EAI\Documents\Visual Studio 2010\Projects\GXCTV1\GXCTV1\FMWTK.cs:行号 485
在 System.Windows.Forms.Control.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
在 System.Windows.Forms.Button.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
InnerException: