[Mono-bugs] [Bug 469217] Pointers can not reference marshaled structures.

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sun Jan 25 13:18:53 EST 2009


User eugeny.grishul at gmail.com added comment

--- Comment #2 from Eugeny Grishul <eugeny.grishul at gmail.com>  2009-01-25 11:18:50 MST ---
I found ability to pass pointers in Mono docs:

 struct Item {
    [DllImport ("library")]
    public static unsafe extern 
       bool CreateItem (out Item* item);

    [DllImport ("library")]
    public static unsafe extern void DestroyItem (Item* item);

    [DllImport ("library")]
    public static unsafe extern int GetInfo (Item* item);

I provide more clear example(tested on MS .NET 3.5+SP1):

using System.Runtime.InteropServices;

namespace MonoTest
    unsafe class Program
        static void Main( string[] args )
            printf( ( SomeStruct* ) Marshal.StringToHGlobalAnsi( "this text
appears only in MS.NET VES!\r\n" ).ToPointer() );

        unsafe struct SomeStruct
            public System.IntPtr _ptr;

        [DllImport( "msvcrt.dll" )]
        static extern void printf( SomeStruct* arr );

Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.

More information about the mono-bugs mailing list