Problem with SQLite and a managed code function

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with SQLite and a managed code function

Vladimir Dimitrov
Hello guys,

I am hitting a pretty strange problem right now. Since SQLite does not
support regular expressions I added a custom function with the following
declaration:

     [SqliteFunction (Name = "REGEXP", Arguments = 2, FuncType =
FunctionType.Scalar)]
     public class RegexpFunction : SqliteFunctionEx
     {
         public override object Invoke (object [] args)
         {
             return Regex.IsMatch (Convert.ToString (args [1]),
Convert.ToString (args [0]));
         }
     }

All looks good and works fine on mono and on most Andoid devices but
today I got a tablet (Asus ME371MG) that is causing a really strange
problem. When I try to open a connection to the SQLite db I get this
exception:

Mono.Data.Sqlite.SqliteException: Library used incorrectly
  not an error
    at Mono.Data.Sqlite.SQLite3.CreateFunction (System.String
strFunction, Int32 nArgs, Boolean needCollSeq,
Mono.Data.Sqlite.SQLiteCallback func, Mono.Data.Sqlite.SQLiteCallback
funcstep, Mono.Data.Sqlite.SQLiteFinalCallback funcfinal) [0x00000] in
<filename unknown>:0
    at Mono.Data.Sqlite.SqliteFunction.BindFunctions
(Mono.Data.Sqlite.SQLiteBase sqlbase) [0x00000] in <filename unknown>:0
    at Mono.Data.Sqlite.SQLite3.Open (System.String strFilename,
SQLiteOpenFlagsEnum flags, Int32 maxPoolSize, Boolean usePool) [0x00000]
in <filename unknown>:0
    at Mono.Data.Sqlite.SqliteConnection.Open () [0x00000] in <filename
unknown>:0

If I comment out the function declaration everything works fine until I
need it in some query.

The problem gets even stranger as if I run the code in debug mode then
everything works fine and I don't get the exception. But the problem
happens only when I run the release code...!!!

I tried disabling the code optimization but the problem still appears.

Any ideas?

Thanks
  Vladimir
_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|

Re: Problem with SQLite and a managed code function

Jonathan Pryor-3
On Apr 4, 2014, at 12:54 PM, Vladimir Dimitrov <[hidden email]> wrote:
> The problem gets even stranger as if I run the code in debug mode then everything works fine and I don't get the exception. But the problem happens only when I run the release code...!!!

What link mode does your project have? Is it SdkOnly, or Full?

 - Jon

_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|

Re: Problem with SQLite and a managed code function

Vladimir Dimitrov
It was SDK only. Also I put a Preserve attribute on the class just in case.

But I think I got the problem to some extent. This particular tablet
seems to actually be using x86 architecture somehow. The moment I
enabled the x86 abi for the package the application started working with
SQLite. The question still have is why was everything working in debug
mode while the support for x86 was turned off?

On 4.4.2014 г. 20:49 ч., Jonathan Pryor wrote:

> On Apr 4, 2014, at 12:54 PM, Vladimir Dimitrov <[hidden email]> wrote:
>> The problem gets even stranger as if I run the code in debug mode then everything works fine and I don't get the exception. But the problem happens only when I run the release code...!!!
> What link mode does your project have? Is it SdkOnly, or Full?
>
>   - Jon
>
> _______________________________________________
> Monodroid mailing list
> [hidden email]
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid

_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|

Re: Problem with SQLite and a managed code function

Jonathan Pryor-3

On Apr 5, 2014, at 4:50 PM, Vladimir Dimitrov <[hidden email]> wrote:
> The question still have is why was everything working in debug mode while the support for x86 was turned off?

Debug .apk's contain libmonodroid.so for all ABIs, as this makes deployment easier. Rephrased: Debug builds ignore the $(AndroidSupportedAbis) value (by default).

 - Jon

_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|

Re: Problem with SQLite and a managed code function

Vladimir Dimitrov
Maybe it is worth thinking about that case as other users may experience
the same runtime problems in production with their clients while
everything seems to work in debug mode.

On 6.4.2014 г. 00:32 ч., Jonathan Pryor wrote:

> On Apr 5, 2014, at 4:50 PM, Vladimir Dimitrov <[hidden email]> wrote:
>> The question still have is why was everything working in debug mode while the support for x86 was turned off?
> Debug .apk's contain libmonodroid.so for all ABIs, as this makes deployment easier. Rephrased: Debug builds ignore the $(AndroidSupportedAbis) value (by default).
>
>   - Jon
>
> _______________________________________________
> Monodroid mailing list
> [hidden email]
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid

_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid