By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,813 Members | 2,269 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,813 IT Pros & Developers. It's quick & easy.

C# calling C++ error (instruction at referenced memory could not be read)

P: n/a
Hi,

I have a C# assembly that is calling directly into C++ unmanaged
code. Everything is working fine but at the very end of the process I
get an application error, which says:

"The instruction at (hexNumber) referenced memory at (hexNumber). The
memory could not be read. Click on OK to terminate the program."

It seems to me that the .Net CLR is trying to unload the C++ dll but
hits an issue when it tries to free up some resources. I have read
that this can sometimes occur if there is a buffer overflow. For
example, if you pass in a string or array (by ref) and the C++ code
overruns the array. However, I am not sure if this is my problem.

I am passing in a number of "ref" params into the C++ function, these
are all arrays. I am passing in strings but these are "by value". I
have checked all the values going in and coming out and they all look
the exact same.

Any ideas on his would be greatly appreciated..

Thanks!
gwell

Aug 8 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
gwell wrote:
Hi,

I have a C# assembly that is calling directly into C++ unmanaged
code. Everything is working fine but at the very end of the process I
get an application error, which says:

"The instruction at (hexNumber) referenced memory at (hexNumber). The
memory could not be read. Click on OK to terminate the program."

It seems to me that the .Net CLR is trying to unload the C++ dll but
hits an issue when it tries to free up some resources. I have read
that this can sometimes occur if there is a buffer overflow. For
example, if you pass in a string or array (by ref) and the C++ code
overruns the array. However, I am not sure if this is my problem.

I am passing in a number of "ref" params into the C++ function, these
are all arrays. I am passing in strings but these are "by value". I
have checked all the values going in and coming out and they all look
the exact same.

Any ideas on his would be greatly appreciated..
I'm sorry, but your question is not topical in comp.lang.c++. The
issues you ask are not addressed by ISO/IEC 14882 (either the 1998 or
2003 versions).

Please try a newsgroup with "Microsoft", "Windows", or "dotnet" in the name.

FAQ 5.9 may give you some suggestions.
Aug 8 '07 #2

P: n/a
On Aug 8, 3:54 pm, red floyd <no.s...@here.dudewrote:
gwell wrote:
Hi,
I have a C# assembly that is calling directly into C++ unmanaged
code. Everything is working fine but at the very end of the process I
get an application error, which says:
"The instruction at (hexNumber) referenced memory at (hexNumber). The
memory could not be read. Click on OK to terminate the program."
It seems to me that the .Net CLR is trying to unload the C++ dll but
hits an issue when it tries to free up some resources. I have read
that this can sometimes occur if there is a buffer overflow. For
example, if you pass in a string or array (by ref) and the C++ code
overruns the array. However, I am not sure if this is my problem.
I am passing in a number of "ref" params into the C++ function, these
are all arrays. I am passing in strings but these are "by value". I
have checked all the values going in and coming out and they all look
the exact same.
Any ideas on his would be greatly appreciated..

I'm sorry, but your question is not topical in comp.lang.c++. The
issues you ask are not addressed by ISO/IEC 14882 (either the 1998 or
2003 versions).

Please try a newsgroup with "Microsoft", "Windows", or "dotnet" in the name.

FAQ 5.9 may give you some suggestions.- Hide quoted text -

- Show quoted text -
Hi.. sorry about that... I've posted on the C# forum so hopefully I
might get some help over there. Thanks!

Aug 8 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.