What is the DLL loading behavior when using DllImport[] in C#?

瘦欲@ 提交于 2019-12-11 20:06:38

问题


Using the following code as example:

    [DllImport("C:\\Users\\Rodrigo\\Desktop\\ds08_asio\\dsproEtherFaceAsio\\x64\\Debug\\dsproEtherFaceAsio.dll")]
    public static extern void open_console();

    [DllImport("C:\\Users\\Rodrigo\\Desktop\\ds08_asio\\dsproEtherFaceAsio\\x64\\Debug\\dsproEtherFaceAsio.dll")]
    public static extern int get_available_interface(int index, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder buffer, int maxSize);

    [DllImport("C:\\Users\\Rodrigo\\Desktop\\ds08_asio\\dsproEtherFaceAsio\\x64\\Debug\\dsproEtherFaceAsio.dll")]
    public static extern int get_buffer();

    [DllImport("C:\\Users\\Rodrigo\\Desktop\\ds08_asio\\dsproEtherFaceAsio\\x64\\Debug\\dsproEtherFaceAsio.dll")]
    public static extern int get_channels();

What would be the loading behaviour of the DLL? To be more specific, will each DllImport create one instance of the DLL and export a single function? Or will one instance of the DLL be created and all functions exported?

来源:https://stackoverflow.com/questions/27301840/what-is-the-dll-loading-behavior-when-using-dllimport-in-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!