Ahoj mam problem s nejspise s marsalingem u programu ktery "drive" pod Vistama chodil a dnes pod WIN7 chodit nechce. Nejsem si jist jestli i pod tema Vistama to bylo napsany spravne nic mene chodilo to.
Strucny popis :
Mam nativni C/C++ knihovnu ze ktere volam 2 Ceckove funkce
Header deklarace
struct myCV_TParams{
......
};
void OCRDLL_API initOCR(myCV_TParams parametry, int x_size, int y_size, bool write_params);
void OCRDLL_API recognizeLP(char* imgInput, char * result);
A jejich volani prostrednictvim InteropService
[DllImport("\\OCR_Lib\\ocrvavlej.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.Cdecl)]
protected static extern void initOCR(TParams param, int x_size, int y_size, bool debugFile);
[DllImport("\\OCR_Lib\\ocrvavlej.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern void recognizeLP(IntPtr imgInput, IntPtr result);
Volani metody initOCR(.... ); projde bez chyby tedy TParams je namapovane spravne. Chyba vznika az pri volani metody recognizeLP kde puvodne deklarovane pointry na char predavam nasledovne
public string Process(byte[] data)
{
int sz = data.Length * sizeof(byte);
IntPtr imgInput = Marshal.AllocHGlobal(sz);
Marshal.Copy(data, 0, imgInput, sz);
IntPtr result = Marshal.StringToHGlobalAnsi(".................................................."); // definovana delka 50char v C
OCRLib.recognizeLP(imgInput, result); -> zde vyleti vyjimka AccesViolationException, Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Poradi nekdo kde by mohla byt chyba ??
Diky