Click here to Skip to main content
15,881,424 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a DLL that is to do some low level job that is written in C (or C++). I tried to import it (with DLLImport) in C# and use it, but it doesn't work, but it works in C++. Why a dll can work in C++ but not in C#? How can I fix it?
Thanks in advance.
Posted
Comments
Alan N 7-Jun-12 4:38am    
Have a think about the information someone would need from you before they could answer your question. At the moment I only see "I have this dll and it doesn't work", and that is not enough.
mehdi_k 7-Jun-12 4:43am    
Alan, sorry if my info is not enough, but that is the problem I have here, the only thing I know is that it has the error saying it can not execute and find function.
Alan N 7-Jun-12 4:50am    
No you know a lot more than this!
1) the signature of the method in C/C++ and example C/C++ code for calling the method
2) The DLLImport statement and C# code used to call the method
mehdi_k 7-Jun-12 6:33am    
Yes, I'll post the codes by a few hours.
Richard MacCutchan 7-Jun-12 4:43am    
Easy: there is either a bug in your code, or you have not used the correct marshalling between the C# and C++ on the data that is being passed between the application and the DLL. However, without seeing some of your code it's impossible to guess what or where.

1 solution

"it can not ... find function":
Did you check that you have no typos in your DllImport statement? Did you check the signature of the function, and the marshalling of the parameters?
If you do not cope with these tasks, you sould at least show us the function as it is defined in C, and your DllImport statement.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900