Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I create one class which is inherited from SqliteFunction. I want to use that class as Sqlite function.
I am getting exception while accessing the method "UnsafeNativeMethods.sqlite3_value_blob(xAsIntPtr)". viz:
"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

C#
public static class UnsafeNativeMethods
{
 [System.Runtime.InteropServices.DllImportAttribute("System.Data.SQLite.dll", EntryPoint = "sqlite3_value_blob", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
public static extern IntPtr sqlite3_value_blob([System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.SysUInt)]IntPtr p);
}

[SQLiteFunction(Name = "rank", Arguments = 3, FuncType = FunctionType.Scalar)]
class myFunction: SQLiteFunction
   {

       public override object Invoke(object[] args)
       {
           //return base.Invoke(args);
           return myFunction((byte[])args[0],(long)args[1],(long)args[2]);
       public  static double myFunction(byte[] pCtx, long nVal, long b)
       {
           IntPtr xAsIntPtr = new IntPtr(x);
           long x = b;
           long[] apVal = digitArr(b); //digitArr convert the long to array of long
          long[]matchinfo=digitArr((long)UnsafeNativeMethods.sqlite3_value_blob(xAsIntPtr));//<small>--exception</small>

...Continue
Posted
Updated 20-Jul-15 4:58am
v3

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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