Hi How to return List from c# method and Use the List return values in c++ can u give guidance how to do it?? I going like following way my complete scenario:
in c# DemoLib.cs
usng System;using System.Collections.Generic;
public interface IDiscover
{
void GetList1();
String GetList2();
List<string> GetList3();
};
namespace DemoLibrary
{
class DemoLib
{
public void GetList1()
{
Console.WriteLine(" I am from Void GetList()");
}
public string GetList2()
{
Console.WriteLine(" I am from string GetList()");
return "Stack OverFlow";
}
public List<string> GetList3()
{
List<string> li=new List<string>();
li.Add("India");
li.Add("America");
li.Add("London");
Console.WriteLine(" I am from List<string> GetList()");
return li;
}
Build successfully and created DemoLib.dll
I copy the DemoLib.dll to c:\DemoLib.dll and using regasm created Demolib.tlb in c:\
Now in Vc++ i Hav main()
DemoLibMain.vc++
#include<list>
#include<stdio.h>
void main()
{
HRESULT Hr=CoInitialize(NULL);
IDiscoverPtr Iptr(__uuidof(DemoLib));
Iptr->GetList1();
std::string str=Iptr->GetList2();
printf("%s",str); //dispalys "null" insted of "stack overflow" but when i debugging it
shows the value "stack overflow" at str.
Iptr->(Afraid since it doesnot give GetList3() )
when i forced to write Iptr->GetList3() it Display the error as GetList3 is not a member
of IDiscover;
How to fix this problem what i go wrong in this program. Can any one suggest me plzzz and
Guide ..
Thanks in Advance.