COM object created with c# not registering

D

Daniel Bass

The scenario:
-------------


I've created a simple COM object according to a tutorial I found:

http://www.csharphelp.com/archives/archive281.html

It automatically creates a Type Library (TLB) so that I can hook into the
object using the virtual table provided in the tlb file.

On the development machine, it seems to register the COM into the registry
properly, so I can create an instance of the object (via IDispatch) from
vbscript say (using CreateObject(...) ).

I turned on the option in the config for registering for COM interop.


The problem:
-------------

There's a clean box that I transfer this same script to, and my DLL. But I
can't get it to register on my machine. I've called RegAsm as recommended
for .Net libraries, and that should apparently register is for the COM stuff
as well, but it doesn't work, failing with something like "can't create
component".


Questions:
----------

What is VS.Net doing to register the program on my machine that regasm
isn't?
How to i register this DLL (if this isn't included in the first question)
for use with the IDispatch interface?
 
D

Dmitriy Lapshin [C# / .NET MVP]

Daniel,

The RegAsm.exe tool should do the job. VS .NET possibly also runs TlbExp to
produce the .tlb file after running RegAsm, but I have never had problems
with registering my assemblies with RegAsm.

You could probably post the detailed error message?
 
D

Daniel Bass

Thanks for your reply.

the RegAsm says that it sucessfully registers the Types, and the Type
Library was correctly exported and registered.

the script error I get (when it's embedded in an HTML page) is
"ActiveX component can't create object:
'BIF_COM_API.BIF_Instantiation.Class' "

All the script does at the moment is:

<!--
option explicit

sub VB_Click

Dim bifapi
set bifapi = CreateObject ( "BIF_COM_API.BIF_Instantiation" )
' bifapi.SetDestinationQueueName "Local_In"
' bifapi.Send

end sub
-->

It just gets me why it works a treat on the machine on which i built this
COM object, but not on any other machine.

Thanks again.
Dan.

in message Daniel,

The RegAsm.exe tool should do the job. VS .NET possibly also runs TlbExp to
produce the .tlb file after running RegAsm, but I have never had problems
with registering my assemblies with RegAsm.

You could probably post the detailed error message?
 
D

Dmitriy Lapshin [C# / .NET MVP]

Daniel,

I believe the problem is not with the registration. I'd rather say the COM
exposed object itself lacks some attributes. For instance, instantiating a
COM object within a Web page requires the COM object to be marked as "Safe
for scripting", if this action is at all enabled for the IE security zone
the page is opened in.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Daniel Bass said:
Thanks for your reply.

the RegAsm says that it sucessfully registers the Types, and the Type
Library was correctly exported and registered.

the script error I get (when it's embedded in an HTML page) is
"ActiveX component can't create object:
'BIF_COM_API.BIF_Instantiation.Class' "

All the script does at the moment is:

<!--
option explicit

sub VB_Click

Dim bifapi
set bifapi = CreateObject ( "BIF_COM_API.BIF_Instantiation" )
' bifapi.SetDestinationQueueName "Local_In"
' bifapi.Send

end sub
-->

It just gets me why it works a treat on the machine on which i built this
COM object, but not on any other machine.

Thanks again.
Dan.

in message Daniel,

The RegAsm.exe tool should do the job. VS .NET possibly also runs TlbExp to
produce the .tlb file after running RegAsm, but I have never had problems
with registering my assemblies with RegAsm.

You could probably post the detailed error message?

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Daniel Bass said:
The scenario:
-------------


I've created a simple COM object according to a tutorial I found:

http://www.csharphelp.com/archives/archive281.html

It automatically creates a Type Library (TLB) so that I can hook into the
object using the virtual table provided in the tlb file.

On the development machine, it seems to register the COM into the registry
properly, so I can create an instance of the object (via IDispatch) from
vbscript say (using CreateObject(...) ).

I turned on the option in the config for registering for COM interop.


The problem:
-------------

There's a clean box that I transfer this same script to, and my DLL. But I
can't get it to register on my machine. I've called RegAsm as recommended
for .Net libraries, and that should apparently register is for the COM stuff
as well, but it doesn't work, failing with something like "can't create
component".


Questions:
----------

What is VS.Net doing to register the program on my machine that regasm
isn't?
How to i register this DLL (if this isn't included in the first question)
for use with the IDispatch interface?
 
D

Daniel Bass

That's fair comment, but it still doesn't explain the reason for it working
fine one the machine on which it is compiled, and not on any others. This
forces me to disagree with you on the fact that it must be something in the
registry?

I've just created a little COM dll from VB's COM template, but this has the
same affect... there must be some switch somewhere to allow this?

Dan.

in message Daniel,

I believe the problem is not with the registration. I'd rather say the COM
exposed object itself lacks some attributes. For instance, instantiating a
COM object within a Web page requires the COM object to be marked as "Safe
for scripting", if this action is at all enabled for the IE security zone
the page is opened in.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Daniel Bass said:
Thanks for your reply.

the RegAsm says that it sucessfully registers the Types, and the Type
Library was correctly exported and registered.

the script error I get (when it's embedded in an HTML page) is
"ActiveX component can't create object:
'BIF_COM_API.BIF_Instantiation.Class' "

All the script does at the moment is:

<!--
option explicit

sub VB_Click

Dim bifapi
set bifapi = CreateObject ( "BIF_COM_API.BIF_Instantiation" )
' bifapi.SetDestinationQueueName "Local_In"
' bifapi.Send

end sub
-->

It just gets me why it works a treat on the machine on which i built this
COM object, but not on any other machine.

Thanks again.
Dan.

in message Daniel,

The RegAsm.exe tool should do the job. VS .NET possibly also runs TlbExp to
produce the .tlb file after running RegAsm, but I have never had problems
with registering my assemblies with RegAsm.

You could probably post the detailed error message?

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Daniel Bass said:
The scenario:
-------------


I've created a simple COM object according to a tutorial I found:

http://www.csharphelp.com/archives/archive281.html

It automatically creates a Type Library (TLB) so that I can hook into the
object using the virtual table provided in the tlb file.

On the development machine, it seems to register the COM into the registry
properly, so I can create an instance of the object (via IDispatch) from
vbscript say (using CreateObject(...) ).

I turned on the option in the config for registering for COM interop.


The problem:
-------------

There's a clean box that I transfer this same script to, and my DLL. But I
can't get it to register on my machine. I've called RegAsm as recommended
for .Net libraries, and that should apparently register is for the COM stuff
as well, but it doesn't work, failing with something like "can't create
component".


Questions:
----------

What is VS.Net doing to register the program on my machine that regasm
isn't?
How to i register this DLL (if this isn't included in the first question)
for use with the IDispatch interface?
 
J

José Joye

I think I used to have a similar problem.

try to use the /codebase option with regasm command

José
 
D

Daniel Bass

IT WORKS!!!

Thanks so much. =o)

Dan.

I think I used to have a similar problem.

try to use the /codebase option with regasm command

José
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top