What does it mean Platform Challenge (P / Invoke)?
What does running P / Invoke mean? Is this an external dll call ? eg:.
[DllImport("coredll.dll", SetLastError=true)] private static extern bool SHGetSpecialFolderPath( int hwndOwner, string lpszPath, ceFolders nFolder, bool fCreate);
Is that what P / Invoke means: use the [DllImport] attribute?
Is there anything else that can be considered P/Invoke ?
How about [ComImport] ? eg:.
[System.Runtime.InteropServices.ComImport] [Guid("F8383852-FCD3-11d1-A6B9-006097DF5BD4")] public class ProgressDialog { }
Note This COM class (F8383852-FCD3-11d1-A6B9-006097DF5BD4) can be found in
HKEY_CLASSES_ROOT\CLSID\{F8383852-FCD3-11d1-A6B9-006097DF5BD4} (default) %SystemRoot%\system32\shell32.dll ThreadingModel Both
I could also build my own ADO Recordset object with code:
[System.Runtime.InteropServices.ComImport] [Guid("00000535-0000-0010-8000-00AA006D2EA4")] public class Recordset { } Object rs= new Recordset();
Is it considered P / Invoke?
If we want to say that “P / Invoke is bad”, is ComImport “bad” like DllImport?
What does it mean Platform Challenge (P / Invoke)?
Update : from MSDN:
Invocation Services for Platforms (PInvoke) allows you to manage managed code unmanaged functions implemented in DLLs.
There are two ways that C # code can call unmanaged code:
I think I may have answered my question.
This is in a year and a half. Now that no one pays attention to this question, and no one has this, I can say that the answer I accepted is erroneous. P/Invoke short for Platform Invoke . This is a mechanism in which managed code running inside the CLR can invoke unmanaged native (e.g., platform) code. This is almost always done by calling code that resides in the native DLL. COM dll is native code; they simply follow a strict structure that allows many different compilers to call them.
And Platform Invoke is bad. It bypasses the entire garbage collection and is platform dependent (i.e., my 32-bit CLR process cannot load a 64-bit DLL, my application written for Android cannot work on Windows, my application written for functionality on Windows 8 , Windows XP will not work).