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. Managed C++/CLI
  4. Passing structure form VC++ to C# Dll

Passing structure form VC++ to C# Dll

Scheduled Pinned Locked Moved Managed C++/CLI
helpcsharpc++
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.
  • A Offline
    A Offline
    Anu_Bala
    wrote on last edited by
    #1

    Hi, im using C# dll in VC++ application.I have somedetails in VC++ like PageNumer pageTitle PageDesc BoxDetail . I have to pass this to C# Dll. So i made one structure in VC++,then i pas that to C#.But i could't do that.Pls help me. VC++ Function:

    struct SCS3OverVwPg
    {
    __int32 iOvrPgNo;
    char sOvrPgTitle[30]; //OverView Page Title
    };

    void CToolTab::SendOverview()
    {
    SCS3OverVwPg *pOverVw = 0;
    pOverVw = new SCS3OverVwPg;
    Globals1::gwtoolbar->SetTree(pOverVw);
    }

    C# function:

    public struct SCS3Over
    {
    Int32 iOvrPgNo;
    char[] sOvrPgTitle;
    }

    public void SetTree(SCS3Over x)
    {
    MessageBox.Show("Data received");
    }

    If i do like this,it shows error error C2664: 'Tabcontrol::ToolBar::SetTree' : cannot convert parameter 1 from 'SCS3OverVwPg *' to 'SCS3Over' If i change name in C# dll to SCS3OverwPg, it show error of structure redifinition Pls help me.

    Anu

    A 1 Reply Last reply
    0
    • A Anu_Bala

      Hi, im using C# dll in VC++ application.I have somedetails in VC++ like PageNumer pageTitle PageDesc BoxDetail . I have to pass this to C# Dll. So i made one structure in VC++,then i pas that to C#.But i could't do that.Pls help me. VC++ Function:

      struct SCS3OverVwPg
      {
      __int32 iOvrPgNo;
      char sOvrPgTitle[30]; //OverView Page Title
      };

      void CToolTab::SendOverview()
      {
      SCS3OverVwPg *pOverVw = 0;
      pOverVw = new SCS3OverVwPg;
      Globals1::gwtoolbar->SetTree(pOverVw);
      }

      C# function:

      public struct SCS3Over
      {
      Int32 iOvrPgNo;
      char[] sOvrPgTitle;
      }

      public void SetTree(SCS3Over x)
      {
      MessageBox.Show("Data received");
      }

      If i do like this,it shows error error C2664: 'Tabcontrol::ToolBar::SetTree' : cannot convert parameter 1 from 'SCS3OverVwPg *' to 'SCS3Over' If i change name in C# dll to SCS3OverwPg, it show error of structure redifinition Pls help me.

      Anu

      A Offline
      A Offline
      Andreoli Carlo
      wrote on last edited by
      #2

      the structure (SCS3Over ) in c# dll is public? if it's public you can directly use it in visual c++ without having to redeclare it...so your visual c code:

      //struct SCS3OverVwPg 
      //{ 
      // __int32 iOvrPgNo;       
      // char sOvrPgTitle[30]; //OverView Page Title 
      //}; 
        
      void CToolTab::SendOverview() 
         {  
           //SCS3OverVwPg *pOverVw = 0; 
           //pOverVw = new SCS3OverVwPg;     
           Globals1::SCS3Over tmp; //use the correct namespace to go to SCS3Over
           tmp.iOvrPgNo=1;
           tmp.sOvrPgTitle="ciao";
           Globals1::gwtoolbar->SetTree(tmp); 
         }
      
      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