Click to See Complete Forum and Search --> : Early binding
Jerod
March 11th, 2003, 10:05 AM
I am trying to early bind to a 3rd party's unmanaged COM object. I added reference to the tlb which then referenced the new RCW. When I try to create the new object my interfaces do not show, only the enums.
object.interface (<--does work) objName = new object. (<--no interfaces in inteli??)
I am able to late bind to the object though in vb.net but still can't early bind in vb.net or C#? The interfaces do show up in the object explore also.
Thanks for any help,
Jerod
pareshgh
March 11th, 2003, 07:43 PM
Uhh
can't believe that.
do you have a sample ?
Paresh
Jerod
March 12th, 2003, 08:38 AM
If I explicity type in the object.interface I get error "CS0144: Cannot create an instance of the abstract class or interface".
I found an example of where someone else had the same problem with Adobe. Here is the link
http://www.dotnet247.com/247reference/msgs/11/57853.aspx
I went back to VB6 and noticed I couldn't early bind to it there either...
Dim obj as new object.?
but I can...
Dim obj as object.inter
then create it...
But with the 'New' command it's a nogo.
I am able to late bind just like the Adobe post in C#. Note I had to use the class ID also. If I used program ID to create the object I get a null?
Sorry I can't give the exact example because it is to a product my company purchased (Siebel).
Thanks,
Jerod
pareshgh
March 12th, 2003, 01:32 PM
when you will add Acrobat as a ref, the Interops are generated and that generated dll is placed in your debug folder. now that dll is already a .NET wrapper class to talk with Actuall Acrobat reader. so you need not to invoke createobject.
namepace and class creationg should be done simply by new operator
for example,
AcroExch.AVDoc avDoc = new AcroExch.AVDoc();
something like that. you should be able to access the namespace atleast.
Paresh
pareshgh
March 12th, 2003, 01:36 PM
FORGOT TO MENTION
that
Activator.CreateInstance .. you can use but still it requires assembley info. so you can have a look in the generated interopdll by
"ildasm "
viewer
paresh
Jerod
March 12th, 2003, 01:47 PM
I totally agree with you, once an wrapper has been created and you have refence to it then you should be able to create it. I have looked at it with ildasm and it shows everything as fine and I am able to use the activator.createinstance to late bind but not create as new in order to ealy bind. But what would cause the "Cannot create an instance of the abstract class or interface" error? And i wonder why I couldn't even do it in VB6 (now that I have gone back to try it) with the original TLB that could be preventing it? Maybe it's not a dual interfaced type library? Is there a way I can tell?
I appreciate you help,
Thanks,
Jerod
pareshgh
March 12th, 2003, 01:55 PM
Ah, I think the basic class you have is Abstract class !
you can't create an instance of interface or Abstract class . I mean using new opreator.
the class which is derived from Abstract class can be instantiated ..
check out for that. may be that's the one which is causing the big problem..
in past I had seen that. for example
SolidBrush is a derived class from Brush
so for example
Brush b = new Brush();
if I do this then compiler will complain for
" Cannot create an instance of the abstract class or interface 'System.Drawing.Brush' "
but I can obviously
do
1)
Brush b = new SolidBrush(Color.Red);
OR
2)
SolidBrush b = new SolidBrush(Color.Red);
so , you should check which class is deriving your main class and then go from there.
In real world it make more sense to have a Word Document or
SolidBrush rather than Just a Document or Brush.
Paresh
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.