Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

safearray access violation C++ DLL called by VB

Status
Not open for further replies.

rimcon

Technical User
Aug 13, 2005
1
CA
I'm reading data into arrays from a spreadsheet using a VBA macro, which then passes them to a C++ DLL in a function that uses SAFEARRAY e.g.:

in VBA: Call Cholesky(IssuerCorrel(), CF(), ByVal IssuerCount)

in C++: void __declspec (dllexport) __stdcall Cholesky(
SAFEARRAY **IssuerCorrel, SAFEARRAY **CF, short IssuerCount)

The DLL identifies new arrays pointing at the same memory locations e.g.:

double* CFc;
CFc = (double*)(*CF)->pvData;
CFc[0]= *CFc;

reads some arrays, and writes to others. The program then returns to VBA and writes the results back to the spreadsheet.

I keep getting access violations, either reading or writing to the arrays in C++, that lock up excel. I got one version to run, and it looped through the Call Cholesky part 50,000 times per run for 5 or 6 runs. Then I expanded the DLL and haven't got it to run again.

I've been at this for a week. Read tons of articles and forum tips. Can anyone tell me what I'm doing wrong? I'm using Visual Studio.net 2003, excel 2000 and windows xp.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top