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. Calling C# class library in VC++6.0.......

Calling C# class library in VC++6.0.......

Scheduled Pinned Locked Moved C#
questioncsharpc++comhelp
3 Posts 3 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.
  • D Offline
    D Offline
    DasdaDAS
    wrote on last edited by
    #1

    I built a class library in C#. It consists of one public method as shown below. public int calculate(int x,int y) { return x+y; } And I built the .tlb file using Regasm.exe for using it in VC++ 6.0. I created the object for the interface also. but, I can't call the methods in the class. I instatiated in the the interface as follows. void CDialogDlg::OnButton4() { MYSampleLib::_SampleClassPtr ptr;//(__uuidof(MYSampleLib::_SampleClass)); ptr.CreateInstance(__uuidof(MYSampleLib::_SampleClass)); int i = ptr.calculate(90,80); } I got the following error. error C2039: 'calculate' : is not a member of '_com_ptr_t >' what's the Chaos here??????? I'm not sure, this is the correct question in this thread or not ........ Thanks, Zxczc

    J N 2 Replies Last reply
    0
    • D DasdaDAS

      I built a class library in C#. It consists of one public method as shown below. public int calculate(int x,int y) { return x+y; } And I built the .tlb file using Regasm.exe for using it in VC++ 6.0. I created the object for the interface also. but, I can't call the methods in the class. I instatiated in the the interface as follows. void CDialogDlg::OnButton4() { MYSampleLib::_SampleClassPtr ptr;//(__uuidof(MYSampleLib::_SampleClass)); ptr.CreateInstance(__uuidof(MYSampleLib::_SampleClass)); int i = ptr.calculate(90,80); } I got the following error. error C2039: 'calculate' : is not a member of '_com_ptr_t >' what's the Chaos here??????? I'm not sure, this is the correct question in this thread or not ........ Thanks, Zxczc

      J Offline
      J Offline
      John Fisher
      wrote on last edited by
      #2

      You should probably ask this in the VC++ forum, not C#. However, even though it's been a while since I did this sort of thing in VC++, I believe you will first need to change ptr.calculate to ptr->calculate. John
      "You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.

      1 Reply Last reply
      0
      • D DasdaDAS

        I built a class library in C#. It consists of one public method as shown below. public int calculate(int x,int y) { return x+y; } And I built the .tlb file using Regasm.exe for using it in VC++ 6.0. I created the object for the interface also. but, I can't call the methods in the class. I instatiated in the the interface as follows. void CDialogDlg::OnButton4() { MYSampleLib::_SampleClassPtr ptr;//(__uuidof(MYSampleLib::_SampleClass)); ptr.CreateInstance(__uuidof(MYSampleLib::_SampleClass)); int i = ptr.calculate(90,80); } I got the following error. error C2039: 'calculate' : is not a member of '_com_ptr_t >' what's the Chaos here??????? I'm not sure, this is the correct question in this thread or not ........ Thanks, Zxczc

        N Offline
        N Offline
        Nick Parker
        wrote on last edited by
        #3

        You might try reading my article covering this topic: Exposing .NET Components to COM[^]

        - Nick Parker Microsoft MVP - Visual C#
        My Blog | My Articles

        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