用户定义的类的对象/类数组失败
我希望有更多 C++ 知识的人能够帮助我。我正在尝试从我在托管 C++ DLL 中创建的类中创建 C# 中的对象数组。我不知道发生了什么事。我能够运行应用程序并构建它,设置类数组似乎工作得很好,但是当我从数组中调用函数时,它永远不会研究托管 DLL。我已经追踪过它,但它根本不起作用。该应用程序也不会因任何错误而失败。有趣的是,当我删除了一系列类,并且只有在一切正常且运行良好的情况下才启动该类时。请帮我弄清楚如何解决这个问题。
//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);
};
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);
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来您从未初始化过数组
doesn't look like you ever initialize the array