Arijeet Ghosh

Arijeet Ghosh

  • NA
  • 210
  • 37.8k

I have written the code but still comes error

Jul 1 2020 3:19 AM
I have written this code but still can't find the function. Please help me rectify the problem.
 
The code:-
  1. public partial class Form1 : Form  
  2. {  
  3. public Form1()  
  4. {  
  5. InitializeComponent();  
  6. }  
  7. private void button1_Click(object sender, EventArgs e)  
  8. {  
  9. Test t = new Test();  
  10. IntPtr fooPtr = Test.plus(5, 7);  
  11. int LENGTH = 0;  
  12. var foo = new int[LENGTH];  
  13. Marshal.Copy(fooPtr, foo, 0, LENGTH);  
  14. MessageBox.Show(LENGTH.ToString());  
  15. }  
  16. }  
  17. internal sealed class Test  
  18. {  
  19. [DllImport("F://test_Multiple//MFCApplication2//Debug//MFCApplication2.exe", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]  
  20. public static extern IntPtr plus(int a, int b);  
  21. }  

Answers (2)