[Mono-dev] string marshalling conversion 34 not implemented
Josh
TwoOneSix at thatclothingco.com
Sat Apr 5 21:59:32 EDT 2008
On Sat, Apr 5, 2008 at 6:17 PM, Josh <TwoOneSix at thatclothingco.com> wrote:
> On Sat, Apr 5, 2008 at 3:42 PM, Jonathan Chambers <joncham at gmail.com>
> wrote:
>
> > Hello Josh,
> > You didn't post the signature of your pinvoke function, but it
> > looks like you are trying to marshal a string using UnmanagedType.VBByRefStr.
> > This does seem to be a limitation in mono (and not fixed in svn head),
> > however the docs seem to indicate that this should only be used for VB
> > compatibility. If you are changing/return the string in unmanaged, you need
> > to use a StringBuilder. If you are only passing a string in, you can just
> > pass a string (and specify the native string type).
> >
> > See this great page on the wiki for more info:
> >
> > http://www.mono-project.com/Interop_with_Native_Libraries
> >
> > Thanks,
> > Jonathan
> >
> > 2008/4/4 Josh <TwoOneSix at thatclothingco.com>:
> >
> > > Mono is throwing me the error "string marshalling conversion 34 not
> > > implemented" when I'm attempting to call a function to libvlc.dll from my
> > > code. The other calls to the DLL work fine, but the AddTarget Function
> > > causes the error. I'm getting the same results on both Windows and Linux
> > > versions.
> > >
> > > [AddTarget Function]
> > > ===============================
> > > public Err AddTarget(string Target)
> > > {
> > > if ((m_iVlcHandle == -1)) {
> > > m_strLastErr = "LibVlc is not initialzed";
> > > return Err.NoInit;
> > > }
> > > Err enmErr = Err.Success;
> > > try {
> > > enmErr = VLC_AddTarget(m_iVlcHandle, Target, null, 0,
> > > (int)Mode.Append, (int)Pos.Close);
> > > }
> > > catch (Exception ex) {
> > > m_strLastErr = ex.Message;
> > > return Err.Execption;
> > > }
> > > if (((int)enmErr < 0)) {
> > > m_strLastErr = VLC_Err((int)enmErr);
> > > return enmErr;
> > > }
> > > // OK
> > > return Err.Success;
> > > }
> > > ===============================
> > >
> > > [Mono Details - Windows]
> > > ===============================
> > > Mono JIT compiler version 1.9 (tarball)
> > > Copyright (C) 2002-2007 Novell, Inc and Contributors.
> > > www.mono-project.com
> > > TLS: normal
> > > GC: Included Boehm (with typed GC)
> > > SIGSEGV: normal
> > > Notification: Thread + polling
> > > Architecture: x86
> > > Disabled: none
> > > ===============================
> > >
> > > [Mono Details - Linux]
> > > ===============================
> > > Mono JIT compiler version 1.9 (tarball)
> > > Copyright (C) 2002-2007 Novell, Inc and Contributors.
> > > www.mono-project.com
> > > TLS: __thread
> > > GC: Included Boehm (with typed GC)
> > > SIGSEGV: normal
> > > Notifications: epoll
> > > Architecture: x86
> > > Disabled: none
> > > ===============================
> > >
> > > Any ideas? Might this be fixed in HEAD? I'm also up to using a
> > > different media player that is "known to work" in mono.
> > >
> > > Josh
> > >
> > > _______________________________________________
> > > Mono-devel-list mailing list
> > > Mono-devel-list at lists.ximian.com
> > > http://lists.ximian.com/mailman/listinfo/mono-devel-list
> > >
> > >
> >
>
> Jonathan, I think that the code I'm using was converted from a VB source.
> Here is the VB PInvoke function I dug up from that code:
> [code]
> Private Declare Function VLC_AddTarget Lib "libvlc" (ByVal iVLC As
> Integer, ByVal Target As String, ByVal Options() As String, ByVal
> OptionsCount As Integer, ByVal Mode As Integer, ByVal Pos As Integer) As Err
> [/code]
>
> That URL you provided looks like it's going to be spot-on what I need to
> fix the problem, thank you!. If I come across any other issues I'll post
> back. Also, if anyone knows of a working mono sample using libvlc it would
> be much appreciated.
>
> Thanks again.
>
> Josh
>
Jonathan,
To follow up, you are the man. The magic answer was changing over to
StringBuilder (http://msdn2.microsoft.com/en-us/library/2839d5h5(VS.71).aspx).
All I had to do was switch the P/Invoke signature from type "String" to
"StringBuilder" and go through and tell my code to pass in a StringBuilder
and Vio-la! it works using libvlc.dll both in the Linux and Windows versions
of mono (and still works fine in .NET, too).
Thank you for your help, now I can move on to the final 43 errors MoMA is
reporting. ;-)
Thanks again!
Josh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20080405/7ff80427/attachment-0001.html
More information about the Mono-devel-list
mailing list