I have a DLL written in C++, and it contains functionality that I need for a C# program I'm writing.
I know the names of the methods that I need, in fact I have all the method names in the DLL file, it's just using them that I'm having a problem with. Originally I thought I was out of luck because I couldn't add the DLL as a reference to my solution, but I found out how to use DllImport and tried that, but I couldn't get anywhere, so I searched Google and came up with something. This is my code for one of the functions in FATXLib.dll:
Yeah, the word device is spelled wrong in the dll, so I kept it that way.
Anyway, I then have this method:
And finally I have a button on my form which, when clicked, does this:
At which point I get this error:
Cannot marshal 'return value': Generic types cannot be marshaled.
I'm stumped. How can I get around this?
I know the names of the methods that I need, in fact I have all the method names in the DLL file, it's just using them that I'm having a problem with. Originally I thought I was out of luck because I couldn't add the DLL as a reference to my solution, but I found out how to use DllImport and tried that, but I couldn't get anywhere, so I searched Google and came up with something. This is my code for one of the functions in FATXLib.dll:
Code:
[DllImport("FATXLib.dll")]
public static extern List<string> CheckDivices(FATX.DeviceType.Types DeviceToSearchFor);
Anyway, I then have this method:
Code:
public static List<string> Main2()
{
return CheckDivices(FATX.DeviceType.Types.FATX_DEVICE_360HDD);
}
Code:
private void button1_Click(object sender, EventArgs e)
{
List<string> devices = Main2();
MessageBox.Show(devices.Count.ToString());
}
Cannot marshal 'return value': Generic types cannot be marshaled.
I'm stumped. How can I get around this?
Comment