[Mono-dev] PInvoke Problem on Ubuntu
Jonathan Chambers
joncham at gmail.com
Fri Mar 18 15:42:19 EDT 2011
You didn't post the C code you are p-invoking, but note the char type is
2-bytes in C#. That means if you have a char in the C signature, I believe
the code presented here is wrong.
Thanks,
Jonathan
On Thu, Mar 17, 2011 at 8:13 PM, erasmus777 <el_gerbo2 at yahoo.com> wrote:
> I'm trying to test Pinvoke on Ubuntu, but it looks like other people are
> also
> having problems with it on the latest Mono build.
>
> Here's my IPy code:
>
> import clr
> clr.AddReference('pinvoketest')
> from pinvoketest import PinvokeTest
>
> Invoke.WriteToFile('t')
>
>
> My C# Wrapper:
>
> namespace PinvokeTest {
> using System;
> using System.Runtime.InteropServices;
>
> public static class Invoke
> {
> [DllImport("libpinvoke.so", SetLastError=true)]
> static extern void pinvoke_this(char input);
>
> public static void WriteToFile(char arg)
> {
> pinvoke_this(arg);
> return;
> }
> }
> }
>
>
> Calling the native assembly works fine with ctypes in CPython, so the
> problem is either in my .NET code or Mono. Is there something wrong with
> my approach or is this an issue with Mono?
>
> Thanks
>
> --
> View this message in context:
> http://mono.1490590.n4.nabble.com/PInvoke-Problem-on-Ubuntu-tp3385915p3385915.html
> Sent from the Mono - Dev mailing list archive at Nabble.com.
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20110318/e7b4ea1e/attachment.html
More information about the Mono-devel-list
mailing list