PInvoke restriction: cannot return variants error RRS feed

  • Question

  • Hi,

     I am trying to use a C++ dll in my C# app.  The method that I am calling returns a class.  I am tyring to use the "dynamic" keyword to auto create my class on the C# side.  But when I do, I get a "PInvoke restriction: cannot return variants" error

    Here is my code:

    [DllImport("mylib.dll", CharSet = CharSet.Unicode)]
    public static extern dynamic getCar(string carType);
    protected void Page_Load(object sender, EventArgs e)
    Is there some other way to do this?

    • Edited by BigOnion Tuesday, August 28, 2018 3:18 PM
    Tuesday, August 28, 2018 3:18 PM


All replies