1

I have function in C

void GetCharArray(char* arrayNew[5])
{
arrayNew[5]= {"Test", 
            "Test2",
            "Test4",
            "Test5",
            "Test6",        

    };  
}

extern "C" __declspec(dllexport) void GetCharArray(char* arrayNew[5]);

Want to call it from my C# code as following

   [DllImport(@"Test.dll",
        CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]       
    public static extern void GetCharArray(String[] sbOut);

 List<string> testList = new List<string>();
 GetCharArray(testList .ToArray());

I want my testList to be populated by values from C code.Am I marshaling it in right way.As when the debugger is reaching GetCharArray() function it is showing no entry point found. Kindly Help.

4
  • Are you sure you don't want a char[,] array from your C code? Commented Jul 18, 2012 at 14:55
  • 1
    First try to write working C function. Commented Jul 18, 2012 at 14:55
  • @AlexFarber - Thanks a lot for reply. I am not very good in C programming. I am basically .net guy. Can you please correct if there is anything wrong in my c function. Commented Jul 18, 2012 at 16:43
  • @BryanCrosby - I want a parameter as string array for the C function which I want to populate with strings in the function itself. Can you help me with the C function itself and then with marshalling part Commented Jul 18, 2012 at 16:47

1 Answer 1

1

No entry point found. Means it cannot find the symbol. Although the function name is GetCharArray its symbol name is not named exactly GetCharArray. Make sure when you compile the native DLL you export symbols and create linker definition and name the symbol so that DllImport can function properly. If you need more help I can supply more information. I think I know why it is not working because I had a similar problem because I used DllImport correctly.

External Resources

P.S. There is also a command line tool to dump information from the DLL to retrieve the exact symbol name. The naming convetions of symbols vary.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.