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. Problem in accessing C# dll in VC 6.0 project

Problem in accessing C# dll in VC 6.0 project

Scheduled Pinned Locked Moved C#
helpcsharpc++com
3 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.
  • 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 <stdio.h> 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.

    C 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 <stdio.h> 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.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      I assume the tlb means you've created a COM dll. Have you tried specifying the GUID directly, instead of using the smart pointer stuff ? Also, why are you sure the class name gets a _ put in front of it in VC ? You'd do better to upgrade to a less crap version of C++, and then you can just use managed C++ as your bridge.

      Christian Graus Driven to the arms of OSX by Vista.

      R 1 Reply Last reply
      0
      • C Christian Graus

        I assume the tlb means you've created a COM dll. Have you tried specifying the GUID directly, instead of using the smart pointer stuff ? Also, why are you sure the class name gets a _ put in front of it in VC ? You'd do better to upgrade to a less crap version of C++, and then you can just use managed C++ as your bridge.

        Christian Graus Driven to the arms of OSX by Vista.

        R Offline
        R Offline
        raesa
        wrote on last edited by
        #3

        My project requirement is that i have to use VC 6.0 Is there a way to solve this problem?I just dont undertsand why the code isn't able to identify my classes.Is there a problem with my tlb file generation.Please do tell me if there is a solution to this ? Thnk you ...

        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