I've now been able to create a COM component out of my smalll project and can access one specified method. The problem is now that when I run my dll through an C# Console Application in Visual Studio I get this error message:
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll
Additional information: Retrieving the COM class factory for component with CLSID {FA11D634-3F6D-4DFF-8FE7-7528A0373411} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
What I have now is:
main.cpp
#include "ItShouldWork_global.h"
#include <QObject>
#include <QAxFactory>
#include <QAxBindable>
class ITSHOULDWORKSHARED_EXPORT ItShouldWork
: public QObject{
Q_OBJECT
Q_CLASSINFO("ClassID", "{fa11d634-3f6d-4dff-8fe7-7528a0373411}")
Q_CLASSINFO("InterfaceID", "{1a41b926-eaec-4beb-9f49-4a914eebc6e1}")
Q_CLASSINFO("RegisterObject", "yes")
public:
QString id
() const { return objectName
();
} };
{
}
{
return a + " - " + b;
}
#include "main.moc"
QAXFACTORY_BEGIN("{f9e2e91a-ca63-4e5a-85b7-5bb65b8ee358}", "{90873f03-a81a-4007-8652-b9c134e72126}")
QAXCLASS(ItShouldWork)
QAXFACTORY_END()
#include "ItShouldWork_global.h"
#include <QObject>
#include <QAxFactory>
#include <QAxBindable>
class ITSHOULDWORKSHARED_EXPORT ItShouldWork : public QObject
{
Q_OBJECT
Q_CLASSINFO("ClassID", "{fa11d634-3f6d-4dff-8fe7-7528a0373411}")
Q_CLASSINFO("InterfaceID", "{1a41b926-eaec-4beb-9f49-4a914eebc6e1}")
Q_CLASSINFO("RegisterObject", "yes")
Q_PROPERTY(QString id READ id)
public:
ItShouldWork(QObject* parent = 0);
QString test(QString a, QString b);
QString id() const { return objectName(); }
};
ItShouldWork::ItShouldWork(QObject* parent) : QObject(parent)
{
}
QString ItShouldWork::test(QString a, QString b)
{
return a + " - " + b;
}
#include "main.moc"
QAXFACTORY_BEGIN("{f9e2e91a-ca63-4e5a-85b7-5bb65b8ee358}", "{90873f03-a81a-4007-8652-b9c134e72126}")
QAXCLASS(ItShouldWork)
QAXFACTORY_END()
To copy to clipboard, switch view to plain text mode
and then when trying to instantiate it in my c# Console application:
Console.WriteLine("Testing: ");
itshouldworkLib.ItShouldWork it = new itshouldworkLib.ItShouldWork();
Console.WriteLine("Worked id: " + it.id);
Console.WriteLine("Testing: ");
itshouldworkLib.ItShouldWork it = new itshouldworkLib.ItShouldWork();
Console.WriteLine("Worked id: " + it.id);
To copy to clipboard, switch view to plain text mode
This stops the program and shows the error message above, any ideas?
Bookmarks