It has to be that way else it wont work at all. In clarion I read the address to get the string value.
If I change the prototype to 'getKlantbyID(String, String),String,Pascal' it does not work.
Main Topics
Browse All TopicsHi,
I've a .DLL file that's made with Clarion. This DLL file does some things and returns a string value.
I want to use some methods of this DLL in my C# program. So I used dllimport with the methods I want to use.
So far so good, but sometimes I get a "Attempted to read or write protected memory" error. Not all the time.
I am not sure if I'm using the DLL import right in this case.
This is my dllimport syntax:
[DllImport("C:\\callcw.dll
public static extern string getKlantbyID(string companyid, string klantid);
and this is the way i call this method:
string xmlPath = getKlantbyID(companyid, klantnummer).ToString();
companyid and klantnummer are both of the type 'string'.
This is the function prototype in Clarion:
getKlantbyID(Long, Long),String,Pascal
The variable it returns is of the type 'CString(500)'
I'm not sure but I think the error has to do with the way I'm using the DLL in C#.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Take a look at this: http://attryde.com/clarion
Especially the 'Passing String Parameters' section at the bottom.
There you will see a VB declaration of P/Invoke using a string and a clarion prototype with a long.
I can try to change the C# signature to use 'int' but how am I going to pass a string to it that way?
Business Accounts
Answer for Membership
by: TheLearnedOnePosted on 2007-07-19 at 06:36:28ID: 19521711
The declaration has Long, Long, and you have string, string:
", EntryPoint = "getKlantbyID")]
[DllImport("C:\\callcw.dll
public static extern string getKlantbyID(int companyid, int klantid);
Bob