creating COM objects

  • Thread starter Thread starter Dan Holmes
  • Start date Start date
D

Dan Holmes

I am creating an aspx application to use our existing COM objects. I
referenced the component correctly and i have it Dimmed correctly. What i
get is "InvalidCastException". Here is the code

Dim cfg as CIBOMConfig.IB_BOMConfig
Dim o as Object
o = CreateObject("CBOMConfig.IB_BOMConfig")
cfg = o ' error happens here.

CIBOMConfig.IB_BOMConfig is not the default interface for this component.
It is one of the implement statements. I can't figure out how to get the
..NET eqivalent of QueryInterface to work. in VB6 the assignment would do
it.

Dan Holmes
 
I don't know if it matters but the implements statement in the VB6 component
is from a type library i created. I didn't reference the dll but the tlb.

Dan Holmes
 
Hi Dan, try this:

Dim cfg As New CIBOMConfig.IB_BOMConfig

and then just use 'cfg' as you would

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations
 
VB won't let me do that. the CIBOMConfig.IB_BOMConfig is underlined green.
Intellisense didn't prompt for that either. It is just an interface though.

Dan Holmes
 
Hi Dan,

If it's an interface, then you can't create an instance of it... You can
create an instance of a class that implements that interface however.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations
 
Back
Top