Question: Is it possible to write a C# dll that can be pinvoked ?
I want to write a replacement library for the WinAPI calls WritePrivateProfileString etc. for reading and writing ini files.
Is it possible to export a function, e.g. ‘WritePrivateProfileString’, implemented in C# so one can pinvoke the dll with DllImport ?
I want to replace the native dll with a managed dll, so the managed dll gets called by the pinvoke call (instead of the native dll, when the managed dll is in the bin directory).
Contrary to popular belief, this is possible. (note that you’ll need to modify the calling application to import from your DLL)
See here.
However, in your case, it’s not necessarily a good idea.
Why don’t you change the
externdeclarations to normal methods that call your replacements?