Board index » delphi » Unable to create COM object from dll. HELP

Unable to create COM object from dll. HELP

Hello,

I use the XMLDOM objects from Microsoft that I use importing the type
library (msxml.dll)

When I use those objects from a standard Delphi (3 or 4) .exe everything
works fine.

When I use it from a standard or activeX DLL (Delphi 3 or 4), it does'nt
work. First, I have to call manually coInitialize(nil) and when I do the
first "coDomDocument.Create", I have the error "class not registered" most
of the time (not always).

Please, this is driving me crazy.

Gilles

 

Re:Unable to create COM object from dll. HELP


Giles:

I sympathize with your frustration.  I have had the same situation numerous
times.  The solution has invariably been to:

1) Be sure the classes in the Dll are registered.  To do this, use the
start|run
comsvr32.exe and specify the dll in question.  Make sure you note the
path to this dll, since you will need it again in step 2.

2) In the D4 Dll project, use project|import type library to re-import  the
type library.  Be absolutely certain you check that the type library you
import is from the same Dll you just finished registering.

3) Close the resulting xxx_TLB.pas file.  This is an annoying feature of D4
that, if you have the TLB.pas file open, the compiler doesn't replace it
until you have recompiled at least once (usually the compiler waits about
5 minutes or so, then tells you that the disk version is later than the one
loaded into the compiler).  By closing the file, you guarantee yourself
that you are compiling the version on disk.

4) Do a project|build on the project which uses the functions in the Dll.

This should do it.  If not, it's quite possible that you are using functions
in the XMLDOM.dll which use other functions (not in XMLDOM.dll) and
that those functions are not registered.

I can't really say why you get the error most, but not all, the time, except
top conjecture that on those rare occasions when everything is right, you
performed (maybe even without realizing) all 4 steps above.

I work with 4 Dlls compiled in VB and used in my D4 project (which is
also a dll, called by a MapBasic application) and the process detailed
above has kept me out of trouble.

Quote
Gilles Koffmann wrote in message <7qm2re$f...@forums.borland.com>...
>Hello,

>I use the XMLDOM objects from Microsoft that I use importing the type
>library (msxml.dll)

>When I use those objects from a standard Delphi (3 or 4) .exe everything
>works fine.

>When I use it from a standard or activeX DLL (Delphi 3 or 4), it does'nt
>work. First, I have to call manually coInitialize(nil) and when I do the
>first "coDomDocument.Create", I have the error "class not registered" most
>of the time (not always).

>Please, this is driving me crazy.

>Gilles

Re:Unable to create COM object from dll. HELP


Hi cliff,

thanks for the answer and sorry for not getting back to you but I was out
not connected to the world....

I remember using this tool comsvr32.exe 2 years ago when I was working with
Delphi 2
but now I can't find this tool anywhere on distinct computers (all running
NT4 workstation) nor the web. Do you have a clue ?

Thanks

Gilles

Cliff Estes <cliff.es...@sgsi.com> a crit dans le message :
7qoqng$i8...@forums.borland.com...

Quote
> Giles:

> I sympathize with your frustration.  I have had the same situation
numerous
> times.  The solution has invariably been to:

> 1) Be sure the classes in the Dll are registered.  To do this, use the
> start|run
> comsvr32.exe and specify the dll in question.  Make sure you note the
> path to this dll, since you will need it again in step 2.

> 2) In the D4 Dll project, use project|import type library to re-import
the
> type library.  Be absolutely certain you check that the type library you
> import is from the same Dll you just finished registering.

> 3) Close the resulting xxx_TLB.pas file.  This is an annoying feature of
D4
> that, if you have the TLB.pas file open, the compiler doesn't replace it
> until you have recompiled at least once (usually the compiler waits about
> 5 minutes or so, then tells you that the disk version is later than the
one
> loaded into the compiler).  By closing the file, you guarantee yourself
> that you are compiling the version on disk.

> 4) Do a project|build on the project which uses the functions in the Dll.

> This should do it.  If not, it's quite possible that you are using
functions
> in the XMLDOM.dll which use other functions (not in XMLDOM.dll) and
> that those functions are not registered.

> I can't really say why you get the error most, but not all, the time,
except
> top conjecture that on those rare occasions when everything is right, you
> performed (maybe even without realizing) all 4 steps above.

> I work with 4 Dlls compiled in VB and used in my D4 project (which is
> also a dll, called by a MapBasic application) and the process detailed
> above has kept me out of trouble.

> Gilles Koffmann wrote in message <7qm2re$f...@forums.borland.com>...
> >Hello,

> >I use the XMLDOM objects from Microsoft that I use importing the type
> >library (msxml.dll)

> >When I use those objects from a standard Delphi (3 or 4) .exe everything
> >works fine.

> >When I use it from a standard or activeX DLL (Delphi 3 or 4), it does'nt
> >work. First, I have to call manually coInitialize(nil) and when I do the
> >first "coDomDocument.Create", I have the error "class not registered"
most
> >of the time (not always).

> >Please, this is driving me crazy.

> >Gilles

Other Threads