I'been developing a library on C# for the last days, and now, I need to build that library into a dll, and use that dll from Qt. The library includes three classes I need to access, and my original idea was to simply build the dll, use dumpcpp to get the headers and use them from Qt along with activeqt, which I have used before.
The problem is that I cannot manage to get the headers from dumpcpp, it fails, returning:
dumpcpp: loading '.\Wrapper.dll' as a type library failed
dumpcpp: error processing type library '.\Wrapper.dll'
The Visual Studio project I'm using is a Class library (.Net Standard), and I'm using building it for x86 architecture. I've seen this link and tried using
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
with the three classes I need in order to get a COM dll which I suppose must be usable by dumpcpp, but it fails with the same error I mentioned before. Almost every documentation I have found is about using C++ dlls on C#, and there's nothing about using dumpcpp with C# dlls.
Do somebody has any ideas on how to get this dll working with dumpcpp, so that I can use it with Qt? I'd be really grateful.
Thanks a lot!
Edit: In case it helps, here it's the basic structure (without the complex funcionality) of the unique main .cs file the dll includes:
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace Wrapper
{
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
public class Device
{
public string host;
public string username;
public string password;
public uint port;
private bool _serverConnected;
public uint serverGroupId { get; private set; }
public uint serverId { get; private set; }
private object[] _cameraIds;
public Device(string host, string username, string password, uint port)
{
this.host = host;
this.username = username;
this.password = password;
this.port = port;
this._serverConnected = false;
Debug.WriteLine("Device Initialized");
}
public bool isConnected() => _serverConnected;
public void onServerConnected(uint serverGroupId, uint serverId)
{
Debug.WriteLine("ServerConnectedEventHandler"); // TODO: Remove, just for testing
_serverConnected = true;
}
public void onServerGroupDisconnected(uint serverGroupId)
{
Debug.WriteLine("ServerGroupDisconnectedEventHandler"); // TODO: Remove, just for testing
_serverConnected = false;
}
}
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
class Player
{
private Device _device;
private static readonly int NUM_FRAMES = 10;
private Frame[] _lastFrames = new Frame[NUM_FRAMES];
private int _toReadFrame, _toReceivedFrame;
public Player(Device device)
{
this._device = device;
_toReadFrame = 0;
_toReceivedFrame = 0;
}
public Frame Image()
{
Frame tmp = _lastFrames[_toReadFrame];
_toReadFrame = (++_toReadFrame) % NUM_FRAMES;
return tmp;
}
void FrameAvailableEventHandler(int width, int height, byte[] data)
{
_lastFrames[_toReceivedFrame] = new Frame(width, height, data);
_toReceivedFrame = (++_toReceivedFrame) % NUM_FRAMES;
}
}
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
class Frame
{
public int width { get; private set; }
public int height { get; private set; }
public byte[] data { get; private set; }
public Frame(int width, int height, byte[] data)
{
this.data = data;
this.width = width;
this.height = height;
}
}
}