TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ridzuan
NA
5
0
How to pass referenced string from c dll to c#
May 8 2010 10:41 AM
I have problem to pass a referenced string to c#. Below are the code for c dll and c#
c dll code
extern "C" __declspec(dllexport) int test(string &msg)
{
msg = "test";
return 0;
}
c# code
[DllImport("c_dll.dll")]
public static extern int test(ref StringBuilder newMsg);
StringBuilder aaa = new StringBuilder();
aaa.append("");
int a = test(ref aaa);
i can compiled it successfully but whenever I tried to run it, I get this error
Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Please help to indicate which part of the code is wrong. Thank you
Reply
Answers (
4
)
Asp.net Menu Problem?
Any software who Check predefined Installed Application on Machine