Export dll method from C++ to C#. Why I need: “ extern ”C“ ”

后端 未结 4 1262
隐瞒了意图╮
隐瞒了意图╮ 2021-01-17 11:31

In my dll there is a method that I want to export.

//Works:

extern \"C\" __declspec(dllexport)

//Wont work

__declsp         


        
4条回答
  •  无人共我
    2021-01-17 12:11

    I have tried this with a function with 1 parameter and you have to use

    [DllImportAttribute("whatever.Dll" ,CallingConvention = CallingConvention.Cdecl)]

    for the import in C# to work. Stdcall statement only works (in the presented situation, not in general ) for functions with no parameters and that return void. Tested in vs2012 express edition.

    As a side note, the dependency walker can be downloaded from http://www.dependencywalker.com/

提交回复
热议问题