How to write an ActiveX DLL in Visual C++, which I should instantiate in Visual Basic..?

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

How to write an ActiveX DLL in Visual C++, which I should instantiate in Visual Basic..?

Hi
I've written an ActiveX DLL in Visual C++ with MFC, I'm able to write
the COM client in Visual C++ which works well. But when I add a reference
in Visual Basic and try to instantiate, I'm getting an error like
'ActiveX components can't create objects". I do know why..? shall I need
to do extra code for working well in Visual Basic.

Re: How to write an ActiveX DLL in Visual C++, which I should instantiate in Visual Basic..?

Is this in-proc or out-of-proc? You have to make sure if it is out-of-proc
that you have the ps.dll built and registered or generate the appropriate
.reg script. There is no need to do anything extra to make this work with
VB. Is your VC++ client using CoCreateInstance or are you using the #import
directive?

Make sure that you have the correct code in VB. Make sure that you are using
the correct coclass. You could look in the .idl or in OLEVIEW to see if
you are using this correctly.

"Raj Kumar s" <raj@nuva.com> wrote:
>
>Hi
>I've written an ActiveX DLL in Visual C++ with MFC, I'm able to write
>the COM client in Visual C++ which works well. But when I add a reference
>in Visual Basic and try to instantiate, I'm getting an error like
>'ActiveX components can't create objects". I do know why..? shall I need
>to do extra code for working well in Visual Basic.
>
>Pl. give me a solution, this is so urgent..!!
>
>Thanks and regards
>Rajkumar
>NUVA Systems Ltd.
>India.

Re: How to write an ActiveX DLL in Visual C++, which I should instantiate in Visual Basic..?

I should set thread model either aprtment or both for your COM object, check
*.rgs file
ThreadingModel = s 'Apartment'

"Raj Kumar s" <raj@nuva.com> wrote:
>
>Hi
>I've written an ActiveX DLL in Visual C++ with MFC, I'm able to write
>the COM client in Visual C++ which works well. But when I add a reference
>in Visual Basic and try to instantiate, I'm getting an error like
>'ActiveX components can't create objects". I do know why..? shall I need
>to do extra code for working well in Visual Basic.
>
>Pl. give me a solution, this is so urgent..!!
>
>Thanks and regards
>Rajkumar
>NUVA Systems Ltd.
>India.

Re: How to write an ActiveX DLL in Visual C++, which I should instantiate in Visual Basic..?

The threading model does not matter with this. The threading model will determine
who provides thread concurrency, the COM or the developer. The threading
model will determine also which type of apartment the object is loaded in.
Be aware if you use the 'BOTH' threading model. There are special precautions
that have to be taken, IE the Free threaded marshaller and cross apartment
object access. Unless you know what you are doing do not aggregate the free
threaded marshaller, it will only bring you grief. Also, I would not use
the .rgs script as it will help to ease installation procedures if you use
a proxy/stub instead.

"Yuri" <putivsky@home.com> wrote:
>
>I should set thread model either aprtment or both for your COM object, check
>*.rgs file
>ThreadingModel = s 'Apartment'
>
>
>"Raj Kumar s" <raj@nuva.com> wrote:
>>
>>Hi
>>I've written an ActiveX DLL in Visual C++ with MFC, I'm able to write
>>the COM client in Visual C++ which works well. But when I add a reference
>>in Visual Basic and try to instantiate, I'm getting an error like
>>'ActiveX components can't create objects". I do know why..? shall I need
>>to do extra code for working well in Visual Basic.
>>
>>Pl. give me a solution, this is so urgent..!!
>>
>>Thanks and regards
>>Rajkumar
>>NUVA Systems Ltd.
>>India.
>