Tuesday, November 22, 2016

C++ dll in C#

Yesterday i was passed on a task to Wrap up a c++ based dll to our c# based code base. And i had to confront lot issues for that, mainly Memory Access violations and Entry Point not found, pass by value and pass by reference issues. So i have made some small check list to help you out.

If you have the source to the c++ better, else lotto of debugging issues caused by your c++ dll will be hard to find,


1) Finding the correct entry point.
    a)If you have  the source use "extern c" in header files,
             This will help you out with the usage of function name and related problems,
    b) Else take the dump and check the function name and use it,

2) Parameter related issues
        Make sure the type are right are you passing by value or reference, some times as simple as StringBuilder can be of great use.

3) Does this dll have any read or write dependencies like logging.
       This did cause a lot of issues, as the dll some time uses file as parameters and at times also write some logs, beware if the logs are written inside the Bin folder, this might cause a rebuild of your app. Also setting up the correct folder paths might be also important with the proper read right access.


will add some examples in future.

No comments:

Post a Comment