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