Click here to Skip to main content
15,881,413 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
HI, 
when I run a visual application 2010 I get this error in try catch as function call test , this function get data from some dlls and C++ 


Error :

{"Attempt to read or write Protected Memory This is often an indicating that other memory is corrupt"} System.Exception {System.AccessViolationException}



Note:
I have tried to see Visual studio settings in  <pre>Tools menu ->Options -> Debugging -> General -> Uncheck this option "Suppress JIT optimization on module load"  AND and the same error still appears or   windows user as administrator  or over writing the camera manufacturer's dll


What I have tried:

declaration of function

[DllImport("NVSSDK.dll", SetLastError = true)]
       public static extern Int32 NetClient_GetAlarmServer(Int32 _iLogonID, ref char[] _pcAlarmServer, ref Int32 _iServerPort );



Calling from C#

char[] _pcAlarmServer = new char[16];
     Int32 _iServerPort = 0;

     try
     {
           // HERE IS THE ERROR
           int iRetx1 = NVSSDK.NetClient_GetAlarmServer(_ulLogonID,
                             ref _pcAlarmServer, ref _iServerPort);
     }
     catch (Exception ex)
     {

     }
Posted
Updated 6-Sep-17 9:41am

1 solution

Basically, something you are passing to NVSSDK.NetClient_GetAlarmServer is wrong, and it's almost certainly the char array. I don't know which SDK you are using, so I can't tell you exactly what to try to fix it, but if the SDK documentation doesn't help, but I'd suggest passing a StringBuilder preloaded with - say - double the required space instead of a char[]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900