[Xapian-devel] C# bindings and string typed return values

Greg freediving at gmail.com
Thu Mar 31 13:38:47 BST 2011


On Thu, Mar 31, 2011 at 11:30 AM, Olly Betts <olly at survex.com> wrote:
> On Wed, Mar 30, 2011 at 01:06:39PM +0200, Gregory wrote:
>> Generally the bindings work perfectly, except when called from an IIS
>> application and only when the function being called returns a string
>> eg. GetTerm() or GetValue(). Which results in the application pool
>> crashing.
>>
>> Digging into the errors seems to yield the following "Attempted to
>> read or write protected memory. This is often an indication that other
>> memory is corrupt."
>>
>> I've done a little research on the topic and found the following
>> http://stackoverflow.com/questions/370079/pinvoke-for-c-function-that-returns-char.
>> Which suggests that the pinvoke implementation for string/char
>> returning functions isn't implemented in a way that supports CLR calls
>> (at least not in IIS).
>>
>> Is there something I could do to fix that on my end or is it something
>> that needs to be changed in the bindings.
>
> I'm not really an expert, but it sounds to me like it would be hard to
> work around, and should be fixed in the bindings.
>
> If you're able, the best approach would probably be for you to either
> modify the generated code for one of these methods so that it works in
> your environment, or produce a cut-down testcase which fails.  Then we
> can usefully raise it with the SWIG developers.
>
> Cheers,
>    Olly
I'm not sure I'm capable enough to modify the genrated code, as to the
testcase in one way it's extremely easy to reproduce (a simple call to
one of the functions that returns a string) on the other hand it
requires the code to be run inside an application pool (IIS) which I'm
not sure SWIG developers would be willing to try out.

On a slightly different topic I was trying to implement a 'Relevant
Items' search using ESet and RSet one snag I came upon was that the
Query constructor in C#, namely the Query constructor that has the
Query.op parameter expects SWIGTYPE_p_std__vectorT_Xapian__Query_t
type next which I'm assuming is supposed to be an array of Queries.
However I can't really create anything of a kind, I've seen multiple
examples in perl and python but those seem to have bindings that allow
passing the iterators etc.

Thanks.



More information about the Xapian-devel mailing list