0 Replies Latest reply on Feb 28, 2003 12:13 PM by 388953

    C++ DLL Exception in extproc.exe (VS.NET)


      Can somebody please help, this is driving me insane.

      The following code is called within a DLL (Written in Visual Studio.NET), it works but when the DLL is unloaded it crashes.

      I call it through PL/SQL. (function defined at end of this email).

      (Unhandled exception at 0x77f525d9 in extproc.exe: 0xC0000005: Access violation reading location 0x00000010)

      extern "C" __declspec(dllexport) int OraTest( )
           int total = 0;
           ODatabase     db;
           ODynaset     odyn;

           OStartup( );
           db.Open( "ora", "scott", "tiger" );

           odyn.Open(db, "select sum(sal) CNT from emp");
           odyn.GetFieldValue("CNT", &total);



           return total;

      I can call this code over and over while the DLL is loaded by the SQL session, but as soon as I quit the sql session, extproc.exe crashes.

      Can anyone help me with this?, or explain what may be going on?

      If I remove the db. and odyn. lines then it works fine, obviously not doing much!!, as soon as I put the db stuff back in it crashes.

      It appears I am handling the db destructor in the correct way (db.Close()) as well, and valid results are returned from the function.

      The PLSQL code is as follows:

      create or replace library jclib as 'D:\my documents desktop\My Documents\Visual Studio Projects\dm3\debug\dm3.dll';
      create or replace function testORA return binary_integer
      as external library jclib name "OraTest" language C;
      SELECT testORA() from dual