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

Interface type <TFunctions> must be public #23

Closed Nordaen closed 4 years ago

Nordaen commented 4 years ago

Hi, I'm trying to call an x86 library from x64 application. When I try to create WrapperProxyFactory variable I got this error:

System.ArgumentException: 'The provided interface type <TFunctions> must be public.
Parameter name: TFunctions'

Using LegacyWrapper 3.0.1.

This is my interface what I try to call (I store it in different file):

[LegacyDllImport("CP5200.dll")]
       public interface IUser32Dll : IDisposable
        {
            [LegacyDllMethod(CallingConvention = CallingConvention.Winapi)]
             int CP5200_Net_Init(uint dwIP, int nIPPort, uint dwIDCode, int nTimeOut);
            [LegacyDllMethod(CallingConvention = CallingConvention.Winapi)]
            int CP5200_Net_SendTagText(int nCardID, int nWndNo, IntPtr pText, int crColor, int nFontSize, int nSpeed, int nEffect, int nStayTime, int nAlignment);

        }

How can I fix that?

zalintyre commented 4 years ago

This is the documentation of the Type.IsPublic method, which LegacyWrapper uses to determine if the interface is public:

true if the Type is declared public and is not a nested type; otherwise, false.

Does this help you?

Nordaen commented 4 years ago

Thanks to this documentation, I figured out what the problem was. My interface was nested. Thank you.