Errore DLL con accesso Dao Vc++
-
martedì 26 giugno 2012 14:54
Buongiorno
Ho convertito una dll che utilizza dao da VS6 a VS2010 in Visual C++.
La Dll è utizzata da un'applicazione scritta in VS2005 c# in cui sono eseguite l seguenti operazioni:
1) OpenDatabase
2) utilizza il metodo "SearchData" che accede al database appena aperto
3) CloseDatabase
Quandoavvio l'applicativo viene richiamato il metodo OpenDatabase che successivamente richiama il metodo "SeatchData" ed infine CloseDatabase. L'appliazione lavova correttamente quando la dll era compilata con VS6 but ma ora, quando richiamo il metodo OpenDatabase tutto lavora correttamente ma quando richiamo il metodo "SearchData" appare un errore quando cerco di acceredere al puntatore del database apero nel metodo "OpenDatabase". L'errore indica "errore tentativo di lettura o scrittura in una rea di memoria riservata". L'unico modo per aggirare il problema è aprire il database all'interno dello stesso metodo "SearchData" , utilizzare l'accesso ai dati, quindi chiudere il database, tuttavia questo metodo appesantisce notevolmente il metodo stesso che richiede un tempo più elevato di esecuzione. Dal mio punto di vista sembra che lo stato delle variabili e dei riferimeti del db non sia mantenuto tra la chiamata di "OpenDatabase" e la chimata "SeachData" . Sto utilizzando già AFX_MANAGE_STATE ( AfxGetStaticModuleState() ) prima di ogni metodo. Avete qualche idea a riguardo ?
- Tipo modificato Nicolò ZilioModerator lunedì 1 ottobre 2012 05:08 In attesa di una risposta dell'OP
Tutte le risposte
-
martedì 26 giugno 2012 13:51
Hello
I have converted a dll that use dao from VS6 to VS2010 in Visual C++.
This Dll is used by a VS2005 c# application for this operations
1) OpenDatabase
2) Use method "SearchData" that access to DB opened before
3) CloseDatabase
When I start application first of all it OpenDatabase the it use "SeatchData", then CloseDatabase. The application worked fine since I was working with VS6 but now when I call OpenDatabase it works fine but when I try to "SearchData" there is an error when I try to used db pointer opened before. The error is "trying to read or write in protected memory". The only way to allow dll to work is to open db, use data to access and close db every inside "SearchData" method, but this require a lot of time each call because I call this method many time. For my point of view it seem that dll doesn't mantein the status of db variable between a call of OpenDatabase and the use of "SearchData" method. I am already using AFX_MANAGE_STATE ( AfxGetStaticModuleState() ) at the begining of each method.
Can you help me ?
Thank you very much
- Unito Irina TurcuMicrosoft Contingent Staff, Owner venerdì 29 giugno 2012 13:57 Thread duplicato.
-
martedì 26 giugno 2012 14:05Moderatore
Hello,
This is an italian forum, so please post in italian.
I've seen you've created the same post on Visual C++ Forum.
Nicolò Zilio
Personal blog: http://nicolozilio.wordpress.com/(With technical articles)
Personal Web site: http://nicolozilio.altervista.org/ -
giovedì 2 agosto 2012 14:57Moderatore
Ciao,
ho visto che sei riuscito a ricevere una risposta nella gerarchia inglese del forum. (Problem with dao used in a dll)
Sei riuscito a risolvere il tuo problema?
Nicolò Zilio
Personal blog: http://nicolozilio.wordpress.com/(With technical articles)
Personal Web site: http://nicolozilio.altervista.org/

