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 / C++ / MFC
  4. Problem accessing C# dll in VC 6.0

Problem accessing C# dll in VC 6.0

Scheduled Pinned Locked Moved C / C++ / MFC
helpcsharpc++com
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.
  • R Offline
    R Offline
    raesa
    wrote on last edited by
    #1

    Hi, i have a small problem i have a csharp dll built in VS2005.I have to access the functions from this dll in my VC++ project done in VC 6.0.My VC project is not able to identify my C# namespace and class.I dont get what the problem is. Please do have a look at my c# code and VC Project code and do let me know if im making some mistake.I have also pasted the errors that i am getting. please do help me...i'm not able to understand the problem. :( C# code: using System; using System.Collections.Generic; using System.Text; namespace TestDllCsharp { public class Class1 { public void PrintMessage () { System.Windows.Forms.MessageBox.Show("Test"); } } } VC Project : #import "TestDllCsharp.tlb" using namespace TestDllCsharp; #include void main() { HRESULT hresult; CLSID clsid; CoInitialize(NULL); hresult=CLSIDFromProgID(OLESTR("TestDllCsharp.Class1"),&clsid); if (hresult == 0) { _Class1 *t; hresult=CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER,__uuidof(_Class1),(LPVOID *) &t); t->PrintMessage (); CoUninitialize(); } } I get errors like : error C2065: '_Class1' : undeclared identifier error C2065: 't' : undeclared identifier Thnx in advance.

    _ S 2 Replies Last reply
    0
    • R raesa

      Hi, i have a small problem i have a csharp dll built in VS2005.I have to access the functions from this dll in my VC++ project done in VC 6.0.My VC project is not able to identify my C# namespace and class.I dont get what the problem is. Please do have a look at my c# code and VC Project code and do let me know if im making some mistake.I have also pasted the errors that i am getting. please do help me...i'm not able to understand the problem. :( C# code: using System; using System.Collections.Generic; using System.Text; namespace TestDllCsharp { public class Class1 { public void PrintMessage () { System.Windows.Forms.MessageBox.Show("Test"); } } } VC Project : #import "TestDllCsharp.tlb" using namespace TestDllCsharp; #include void main() { HRESULT hresult; CLSID clsid; CoInitialize(NULL); hresult=CLSIDFromProgID(OLESTR("TestDllCsharp.Class1"),&clsid); if (hresult == 0) { _Class1 *t; hresult=CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER,__uuidof(_Class1),(LPVOID *) &t); t->PrintMessage (); CoUninitialize(); } } I get errors like : error C2065: '_Class1' : undeclared identifier error C2065: 't' : undeclared identifier Thnx in advance.

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      You cannot directly access a C# class in VC. You will need to create a COM Callable Wrapper (CCW) from the C# class. Look at the documentation on how to create CCWs. Then you can access it from VC like you access a COM component.

      «_Superman_»

      1 Reply Last reply
      0
      • R raesa

        Hi, i have a small problem i have a csharp dll built in VS2005.I have to access the functions from this dll in my VC++ project done in VC 6.0.My VC project is not able to identify my C# namespace and class.I dont get what the problem is. Please do have a look at my c# code and VC Project code and do let me know if im making some mistake.I have also pasted the errors that i am getting. please do help me...i'm not able to understand the problem. :( C# code: using System; using System.Collections.Generic; using System.Text; namespace TestDllCsharp { public class Class1 { public void PrintMessage () { System.Windows.Forms.MessageBox.Show("Test"); } } } VC Project : #import "TestDllCsharp.tlb" using namespace TestDllCsharp; #include void main() { HRESULT hresult; CLSID clsid; CoInitialize(NULL); hresult=CLSIDFromProgID(OLESTR("TestDllCsharp.Class1"),&clsid); if (hresult == 0) { _Class1 *t; hresult=CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER,__uuidof(_Class1),(LPVOID *) &t); t->PrintMessage (); CoUninitialize(); } } I get errors like : error C2065: '_Class1' : undeclared identifier error C2065: 't' : undeclared identifier Thnx in advance.

        S Offline
        S Offline
        Smith
        wrote on last edited by
        #3

        Shouldn't that be Class1 instead of _Class1?

        :beer:

        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