473,395 Members | 2,423 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Great Difficulty calling c++ dll from c#

I am using c# 2010 and need to call a method in an old c++ dll

It keeps giving me the following error:
"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

The function I am trying to call in the dll is

void handle_str_ni(LPCSTR lpcstrCommandLine);

So far this is my code :
Expand|Select|Wrap|Line Numbers
  1. [DllImport((@"c:\Mydll.dll"), EntryPoint="handle_str_ni", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
  2.  
  3. public static extern void handle_str_ni([MarshalAs(UnmanagedType.LPStr)]string sString);
  4.  
  5. [MarshalAs(UnmanagedType.LPStr)]public String f1 = "getp p1";
  6.  
  7. private void button1_Click(object sender, EventArgs e)
  8. {
  9.    handle_str_ni(f1);
  10. }
  11.  
  12.  
Sep 1 '10 #1
2 1317
wizardry
201 100+
try recompiling the old .dll with the new complier. that should take care of your errors. i've ran into that before when i switched ide's.
Sep 1 '10 #2
The dll is regularly compiled
Sep 1 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: R.G. Vervoort | last post by:
I am using a javafunction (onclick in select) in which i am calling a function in php (thats why i send this to both php and javascript newsgroups). in the onclick i call the function...
28
by: SStory | last post by:
Hello Group. I am a VB/VB.NET programmer. I have done some C/C++ years ago. I am considering a job opportunity which is unfortunately in C# and not VB.NET. What is the group's opinion on...
12
by: Ron | last post by:
Greetings, I am trying to understand the rational for Raising Events instead of just calling a sub. Could someone explain the difference between the following 2 scenarios? Why would I want to...
42
by: gt8887b | last post by:
Hello! In his recent newsletter embedded expert Jack Ganssle says that programming students, as well as professional developers should readh "great code" (hight quality/well-crafted code that...
6
by: Brian Link | last post by:
Panicked, as usual. Who says it's great being a sole proprietor? Using MS-SQLServer: Three tables: A_Appointment, AX_Appointment_Entity and E_Entity. AX_Appointment_Entity is an...
9
by: flopbucket | last post by:
Hi, Say I have a baseclass B that has many derived classes, let's say C..Z, for example: class B { }; class C : public B {};
1
by: Kevin Walzer | last post by:
I'm trying to create a custom Tkinter widget class, and I'm having some difficulty getting it set up properly. The class is called MacToolbar, saved in its own module MacToolbar.py, and imported...
47
by: teju | last post by:
hi, i am trying 2 merge 2 projects into one project.One project is using c language and the other one is using c++ code. both are working very fine independently.But now i need to merge both...
3
by: Andrew Falanga | last post by:
Hi, Here's what I've got: <html> <head> <script type="text/javascript"> function foo() { document.write("foo"); alert("foo");
3
by: BenKen | last post by:
Hi all, Please i am having difficulty in adding BCC and CC headers to my email script.i want all inputs to be from the html form i.e the script calling what users enter from a form like this To:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.