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
Jeff Roder
NA
4
0
Problem using string args when calling C++ dll function C#
Jul 28 2009 9:06 AM
Hello All,
Here's my situation. I've got an unmanaged C++ DLL with a simple test function that I am currently working with. It looks like this:
extern
"C"
{
__declspec
(
dllexport
)
void
test(string input) {
cout <<
"Inside test()."
<< endl;
}
};
And on the C# side I have the following:
using
System;
using
System.Collections.Generic;
using
System.Text;
using
System.Runtime.InteropServices;
class
MdsCrypt
{
[
DllImport
(
"MdsCryptDLL"
)]
public
static
extern
void
test(
String
test)
;
}
class
Program
{
static
void
Main()
{
System.
Console
.WriteLine(
"Hello..."
);
MdsCrypt
MdsCrypt;
MdsCrypt
.test(
"test"
);
while
(
true
) ;
}
}
The problem is that during runtime I get feedback that says memory was correupted. Sometimes I get an assertion failure that says
_BLOCK_TYPE_IS_VALID(pHead->nBlockUse)
I don't understand why I can't use String arguments!! If I change the string parameter to int in the test() function, no problems at all.
I could really some help, does anyone have any insight?? Thanks much in advance.
Reply
Answers (
1
)
Windows Services
Load Report Failed Problem