Calling C# class library in VC++6.0.......
-
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
-
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
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
toptr->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. -
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
You might try reading my article covering this topic: Exposing .NET Components to COM[^]
- Nick Parker Microsoft MVP - Visual C#
My Blog | My Articles