CodefoundryDE / LegacyWrapper

LegacyWrapper uses a x86 wrapper to call legacy dlls from a 64 bit process (or vice versa).
MIT License
79 stars 20 forks source link

Int32 GetStr( out String Str) no string out #17

Open Arvidas opened 5 years ago

Arvidas commented 5 years ago

Int32 GetStr( out String Str); Not working, hangs or no Str change.

original: //[DllImport("x32.dll", // CallingConvention = CallingConvention.StdCall, // CharSet = CharSet.Unicode, // EntryPoint = "GetStr")] //public static extern Int32 GetStr( // [MarshalAs(UnmanagedType.BStr)] out String Str // );

zalintyre commented 5 years ago

Can you provide your interface definition and the calling code?

Arvidas commented 5 years ago
    [LegacyDllImport("x32.dll")]
    public interface IGetStr : IDisposable
    {
        [LegacyDllMethod(CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode)]
        Int32 GetStr( out String Str);
    }

 public static Int32 GetStr(ref String str)
{
  return = client.GetStr(out s);
}

String s = ""
GetStr(ref s);

if ( s != "") Ok();
wdstest commented 5 years ago

I am running into a very similar problem, which I logged as "How to call a ref string function?" at https://github.com/CodefoundryDE/LegacyWrapper/issues/18