"System. accessviolationexception: Try to read or write the protected memory when connecting to Oracle. This usually indicates that other memory is damaged ." Error

Source: Internet
Author: User
Tags oracleconnection

Testing server debugging recentlyProgramThe following errors occasionally occur:

System. accessviolationexception: attempts to read or write data to protected memory. This usually indicates that other memory is damaged.
In system. Data. Common. example. ocienvcreate (intptr & envhpp, mode, intptr ctxp, intptr malocfp, intptr ralocfp, intptr mfreefp, uint32 xtramemsz, intptr usrmempp)
In system. Data. oracleclient. tracednativemethods. ocienvcreate (intptr & envhpp, mode Mode)
In system. Data. oracleclient. ocihandle .. ctor (ocihandle parenthandle, htype handletype, mode ocimode, handleflag handleflags)
In system. Data. oracleclient. oracleinternalconnection. openonlocaltransaction (string username, string password, string servername, Boolean integratedsecurity, Boolean Unicode, Boolean omitoracleconnectionname)
In system. Data. oracleclient. oracleinternalconnection.. ctor (oracleconnectionstring connectionoptions)
In system. Data. oracleclient. oracleconnectionfactory. createconnection (dbconnectionoptions options, object poolgroupproviderinfo, dbconnectionpool pool, dbconnection owningobject)
In system. Data. providerbase. dbconnectionfactory. createpooledconnection (dbconnection owningconnection, dbconnectionpool pool, dbconnectionoptions options)
In system. Data. providerbase. dbconnectionpool. Createobject (dbconnection owningobject)
In system. Data. providerbase. dbconnectionpool. usercreaterequest (dbconnection owningobject)
In system. Data. providerbase. dbconnectionpool. getconnection (dbconnection owningobject)
In system. Data. providerbase. dbconnectionfactory. getconnection (dbconnection owningconnection)
In system. Data. providerbase. dbconnectionclosed. openconnection (dbconnection outerconnection, dbconnectionfactory connectionfactory)
In system. Data. oracleclient. oracleconnection. open ()
In rinp. dbutility. oraclehelper. executereader (string connectionstring, commandtype, string commandtext, oracleparameter [] commandparameters)
In rinp. dbutility. dataaccess. executereader (commandtype, string commandtext, oracleparameter [] commandparameters)
In rinp. dbutility. dataaccess. executereader (string commandtext)
In rinp. sgpframework. Caches. cancelocationmappingcache. Prepare ()
In rinp. sysframework. fatcache. cachebase. buildcache ()
In rinp. sysframework. fatcache. cachebase.. ctor ()
In rinp. sgpframework. Caches. cancelocationmappingcache. get_current ()
In rinp. sgpframework. rpc. rpchelper. getlocationinfobyphone (string phonenumber)
In rinp. Services. Boss. subreceive. javaseservice. dealreport (messageheader, string provincecode, string savepath)

Or:

System. accessviolationexception: attempts to read or write data to protected memory. This usually indicates that other memory is damaged.
In system. Data. Common. example. ocienvcreate (intptr & envhpp, mode, intptr ctxp, intptr malocfp, intptr ralocfp, intptr mfreefp, uint32 xtramemsz, intptr usrmempp)
In system. Data. oracleclient. tracednativemethods. ocienvcreate (intptr & envhpp, mode Mode)
In system. Data. oracleclient. ocihandle .. ctor (ocihandle parenthandle, htype handletype, mode ocimode, handleflag handleflags)
In system. Data. oracleclient. oracleinternalconnection. openonlocaltransaction (string username, string password, string servername, Boolean integratedsecurity, Boolean Unicode, Boolean omitoracleconnectionname)
In system. Data. oracleclient. oracleinternalconnection.. ctor (oracleconnectionstring connectionoptions)
In system. Data. oracleclient. oracleconnectionfactory. createconnection (dbconnectionoptions options, object poolgroupproviderinfo, dbconnectionpool pool, dbconnection owningobject)
In system. Data. providerbase. dbconnectionfactory. createpooledconnection (dbconnection owningconnection, dbconnectionpool pool, dbconnectionoptions options)
In system. Data. providerbase. dbconnectionpool. Createobject (dbconnection owningobject)
In system. Data. providerbase. dbconnectionpool. poolcreaterequest (object state)
In system. Threading. _ threadpoolwaitcallback. waitcallback_context (object state)
In system. Threading. executioncontext. Run (executioncontext, contextcallback callback, object state)
In system. Threading. _ threadpoolwaitcallback. Wait mwaitcallbackinternal (_ threadpoolwaitcallback tpwaitcallback)
In system. Threading. _ threadpoolwaitcallback. Wait mwaitcallback (object state)

Or:

Message: $ open oracleconnection failed !. Exception: system. Exception: ocienvcreate failed, returnCode-1, but the error message text is unavailable.
In system. Data. providerbase. dbconnectionpool. Createobject (dbconnection owningobject)
In system. Data. providerbase. dbconnectionpool. poolcreaterequest (object state)
In system. Data. providerbase. dbconnectionfactory. getconnection (dbconnection owningconnection)
In system. Data. providerbase. dbconnectionclosed. openconnection (dbconnection outerconnection, dbconnectionfactory connectionfactory)
In system. Data. oracleclient. oracleconnection. open ()
In rinp. Services. Boss. subreceive. rpchacomponent. Start ()

The error module information captured by Windows is:

Description:
Stopped working

Question signature:
Problem event name: appcrash
Application name: haworker_subreceive.exe
Application version: 4.0.0.0
Application timestamp: 4e66c #
Fault Module name: NTDLL. dll
Fault module version: 6.0.6001.18538
Fault module timestamp: 4cb733e1
Exception Code: c0000005
Exception offset: 0002a6fd
OS Version: 6.0.6001.2.1.0.274.10
Region ID: 2052

After the program is simplified, the core part is very simple, and only one database connection is opened:

 Using (Oracleconnection Cn = New Oracleconnection (" Data Source = (description = (address_list = (address = (Protocol = TCP) (host = 10.10.110.10) (Port = 1521) (CONNECT_DATA = (SERVICE_NAME = UIDB ))); user ID = core; Password = sys; min pool size = 1; Max pool size = 1; enlist = false ")){ Try {Debug. writeline (" $ Begin open oracleconnection. "); CN. open (); debug. writeline (" $ Open oracleconnection success !. ");} Catch (Exception ex) {Debug. writeline (string. Format ("$ Open oracleconnection failed !. Exception: {0} ", Ex. tostring (); console. Readline ();}}
 
 
 
There is no problem with other servers. The two specified test servers occasionally encounter the above exceptions. After analysis, there are two reasons for this problem:
 
1. When one of the related Assembly files of the application is compiled and released, it is forcibly specified as "x86" mode. Therefore, the runtime runs in 32-bit or wow64 mode. The problematic test server is 64-bit. Therefore, in wow64 mode, a 32-bit Oracle driver is automatically searched for to connect to the database during running;
 
2. although the test server has a 32-bit Oracle driver and a 64-bit driver installed at the same time, the 32-bit driver is done by directly downloading the instantclient-basic-win32 driver DLL from the Internet and setting the path, it is tested that the 32-bit driver in this mode has certain problems (the 64-bit driver can be operated in this mode ).
 
 
 
Solution:
 
1. Any CPU mode is used for compiling assembly;
 
2. For a 32-bit Oracle driver, install the Oracle client directly. For programs compiled with any CPU, the 64-bit Oracle driver is automatically used to connect to the database in the 64-bit operating system.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.