I'd like to implement some external (in C-written) DLL-functions to my C# software.
I'm having some problems with the declaration though, since I'd like to pass an array (which will be numerically changed from within the dll-function).
The IDE keeps telling me I'm about to change some memory. The exact message is:
"AccessViolationException was unhandled
Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
Below is a piece of code as far as I've got it now:
Expand|Select|Wrap|Line Numbers
- At the c# side:
- class DSPToolBox
- {
- // Externe DSP dll
- unsafe public static extern double S_MakeMOVRMS(short* arrIn, double* arrR, long Size,
- short Order, double* arrA, double* arrB, double CaliOffset);
- }
- class someother class
- {
- long ret;
- double[] A = ACoeff.A;
- double[] B = ACoeff.B;
- double[] R = ACoeff.Register;
- short* Temp = StartPtr;
- fixed (double* pACoeffA = A)
- fixed (double* pACoeffB = B)
- fixed (double* pACoeffR = R)
- ret = DSPToolBox.S_MakeMOVRMS(Temp, pACoeffR,
- (long)DiskBuffer.Length, Order, pACoeffA, pACoeffB, 0);
- }
- //--------------------------------------------------------------------------------------------------------
- At the dll (c) side:
- double _stdcall __declspec(dllexport) S_MakeMOVRMS
- ( short* arrIn, double* arrR, long Size, short Order, double* arrA, double* arrB,
- double CaliOffset)
- {
- arrR[0] = 5*2;
- blabla....
- return 0;
- }
Does anybody maby know how one could handle this?
Thanks.
-Michiel