PDA

View Full Version : 64 bit COM component



hamidarr
12th November 2014, 01:42
Hi everyone.I had to make a dll from my current source to use in C#.I did it with QAxfactory and Qt 4.8.6 and made a dll and used in C# but when I set target build to 64 bit in vs studio my C# program cannot start because my dll(that I have built from my qt source) was 32 bit.I compiled my qt program 64 bit and made 64 bit dll but when I want to add it as COM component(I register it with Regsvr32.exe) it gives me this error :Self registration for d:\.......dll faild.I compiled it with qt 5.2.1 and the result was the same.What should I do???

#ifndef OBJECTS_H
#define OBJECTS_H

#include <QWidget>
#include <QColor>
QT_BEGIN_NAMESPACE
class QVBoxLayout;
QT_END_NAMESPACE
class QSubWidget;
class CirclesGraphicsScene;
class CirclesGraphicsView;
//! [0]
class Circles : public QWidget
{
Q_OBJECT
Q_CLASSINFO("ClassID", "{d574a747-8016-46db-a07c-b2b4854ee75c}")
Q_CLASSINFO("InterfaceID", "{4a30719d-d9c2-4659-9d16-67378209f822}")
Q_CLASSINFO("EventsID", "{4a30719d-d9c2-4659-9d16-67378209f823}")
Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
Q_PROPERTY(int circleNumber READ circleNumber WRITE setCircleNumber)

void createScene();
public:
Circles(QWidget *parent = 0);

QSize sizeHint() const;
QColor backgroundColor()const;
int circleNumber()const{return _n;}

public slots:

//--general
void setBackgroundColor(QColor color);
void setCircleNumber(int n);

//--axes
void setAxesPen(QColor color, int w , int penStyle);

//--circles
void addCircles(int r, int n, int s, int e);

........//the rest

d_stranz
14th November 2014, 00:35
When you register the COM DLL, are the 64-bit Qt DLLs used by the COM server in the PATH where regsvr32 can find them?

Also, I do not know if Qt COM DLLs need the qwindows.dll in the platforms subdirectory under the location of the COM DLL. Qt executables need this.

hamidarr
14th November 2014, 19:00
Thank you for your replying.I put QtCore4.dll ,QtGui4.dll and my dll(that has been created from source) together in the same directory then I register it with regsvr32 successfully but when I want to add it in visual studio as Com component(toolbox-->right click--->choose Item--->COMcomponent)it give me this error self registration for ......dll faild.

ChrisW67
15th November 2014, 02:47
You need to have all the dependencies of the Qt libraries
http://qt-project.org/doc/qt-5/windows-deployment.html#creating-the-application-package

hamidarr
15th November 2014, 11:30
But I don not have any problem when I make 32 bit dll.I do the same things for 64 bit but it gives me this error.

d_stranz
16th November 2014, 01:12
Is Visual Studio a 64-bit app or a 32-bit app? Many Windows apps have not been ported to 64-bit versions. Just because Visual Studio can generate 64-bit code does not mean that Visual Studio itself is a 64-bit app. If it is a 32-bit app, it probably can't load an in-process 64-bit COM DLL. I don't think you can do anything to fix that. Unlike the change from 16-bit to 32-bit, there is no "thunking" in Windows to allow a 32-bit app to use a 64-bit DLL.

You could try building your COM component as an out-of-process server. Or move into the modern world and not use COM at all :-).

hamidarr
16th November 2014, 10:31
Thank you for replying.Could you tell me how can I build my Com component as an out-of-process server???