View Single Post
Old Dec 12th, 2006, 1:45 PM   #7
Klipt
Hobbyist Programmer
 
Join Date: Dec 2005
Posts: 118
Rep Power: 0 Klipt is an unknown quantity at this point
Ok, I added and referenced a C++ project in a C# solution, and it compiles fine, but when it tries to access the C++ code during runtime it says:

System.IO.FileLoadException was unhandled
Message="Attempt to load an unverifiable executable with fixups (IAT with more than 2 sections or a TLS section.) (Exception from HRESULT: 0x80131019)"

I tried putting the C# call in an 'unsafe' block but it made no difference. Any ideas as to where I'm being stupid? :p

The C# code is in a button click event:
csharp Syntax (Toggle Plain Text)
  1. Adder b;
  2. int c = b.add1(5);
  3. btnClick.Text = c.ToString();

C++ header:
cpp Syntax (Toggle Plain Text)
  1. #ifndef CALC_H
  2. #define CALC_H
  3.  
  4. #pragma managed
  5.  
  6. public value class Adder
  7. {
  8. public:
  9. int add1(int a);
  10. };
  11.  
  12. #endif

C++ code:
cpp Syntax (Toggle Plain Text)
  1. #include "Calc.h"
  2. #include <iostream>
  3.  
  4. #pragma managed
  5.  
  6. int Adder::add1(int a)
  7. {
  8. return a+1;
  9. }
  10.  
  11. int Main()
  12. {
  13. return 0;
  14. }
Klipt is offline   Reply With Quote