views:

224

answers:

1

Hello,

I am hoping someone with some more C++ knowledge might be able to help me. I am trying to create an array of objects in C# from a Class I've created in a Managed C++ DLL. I haven't any clue what is going on. I am able to run the application and build it setting up the array of classes appears to work perfectly fine but when I call a function from the array it never researches the Managed DLL. I've traced it and it simply doesn't work. The application doesn't fail with any errors either. Interestingly enough when I removed the array of classes and only initiated the class once it works all fine and dandy. Please help me figure out how to fix this.

//C#

public ClientBridge[] netlobby;

private void connectToLobby(int lobbyIndex)
{
//lobbyIndex = 0

netlobby[lobbyIndex] = new ClientBridge();

connectLobby[lobbyIndex] = netlobby[lobbyIndex].MMK_Connect(host, lobbyport);

}




//C++ DLL

// This class is the managed reference class
public ref class ClientBridge
{
    public:
     ClientBridge();
     virtual ~ClientBridge();
     bool MMK_Connect(String^ hostpass, UInt16 port);
};
+2  A: 

doesn't look like you ever initialize the array

public ClientBridge[] netlobby = new ClientBridge[MAX_BRIDGES]; // <- gotta initialize

private void connectToLobby(int lobbyIndex)
{

netlobby[lobbyIndex] = new ClientBridge();

connectLobby[lobbyIndex] = netlobby[lobbyIndex].MMK_Connect(host, lobbyport);

}
tster
Same issue. I originally had it initialized like that.
Vin