Le .net qui suit en code natif C ne fonctionne pas, des idéesPourquoi cette P/Invoke explicite ne fonctionne pas?
extern "C" {
TRADITIONALDLL_API int TestStrRef(__inout char* c) {
int rc = strlen(c);
std::cout << "the input to TestStrRef is: >>" << c << "<<" ;
c = "This is from the C code ";
return rc;
}
}
[DllImport("MyDll.dll", SetLastError = true)]
static extern int TestStrRef([MarshalAs(UnmanagedType.LPStr)] ref string s);
String abc = "InOut string";
TestStrRef(ref abc);
À ce stade Console.WriteLine (abc) doit imprimer les « Ceci est du code C », mais n'a pas, des idées sur la Qu'est-ce qui ne va pas ?
Pour votre information - j'ai une autre fonction de test ne pas utiliser la chaîne de type ref, il fonctionne très bien
faire fonctionner dans C en premier. –
Natif C - il fait C .net - ne sais pas :( – Kumar