Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Interop c# and cpp unmanaged [modified]

Interop c# and cpp unmanaged [modified]

Scheduled Pinned Locked Moved C#
csharpc++com
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tomerland
    wrote on last edited by
    #1

    Dear gurus, finally I get totally crazy with interoperability of un/managed code. I have the unmanged Cpp-Class "MyCppClass" with one simple member-function "add()". This class is not shown here. Now I build a managed wrapper class "MyCppClassWrapper". I create an instance of this wrapper in a C#-Program and then I want to call the method "add()". #include "MyCppClass.h" namespace Managed { public ref class MyCppClassWrapper { MyCppClass *pInst; public: int add(int a, int b); }; } // implementation int MyCppClassWrapper::add( int a, int b) { return pInst->add(a,b); } If I the program starts, I get a FileNotFoundException: "The specified module could not be found. (Exception from HRESULT: 0x8007007E)" But if I comment out "return pInst->add(a,b);" then everything works fine. It seems that I cannot call the function add() of the pInst-Pointer. I'm totally lost

    modified on Wednesday, April 9, 2008 10:05 AM

    L 1 Reply Last reply
    0
    • T Tomerland

      Dear gurus, finally I get totally crazy with interoperability of un/managed code. I have the unmanged Cpp-Class "MyCppClass" with one simple member-function "add()". This class is not shown here. Now I build a managed wrapper class "MyCppClassWrapper". I create an instance of this wrapper in a C#-Program and then I want to call the method "add()". #include "MyCppClass.h" namespace Managed { public ref class MyCppClassWrapper { MyCppClass *pInst; public: int add(int a, int b); }; } // implementation int MyCppClassWrapper::add( int a, int b) { return pInst->add(a,b); } If I the program starts, I get a FileNotFoundException: "The specified module could not be found. (Exception from HRESULT: 0x8007007E)" But if I comment out "return pInst->add(a,b);" then everything works fine. It seems that I cannot call the function add() of the pInst-Pointer. I'm totally lost

      modified on Wednesday, April 9, 2008 10:05 AM

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      Tomerland wrote:

      But if I comment out "return pInst->add(a,b);" then everything works fine.

      The code you posted does not show the pInst member being initialized. You can't use it without initializing it to a valid value. Oh and this is the wrong forum for your question. This is a C++/CLI question so if you need more information you should ask in that forum.

      led mike

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups