CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: Early binding

  1. #1
    Join Date
    Mar 2003
    Posts
    3

    Early binding

    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

  2. #2
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    Uhh

    can't believe that.

    do you have a sample ?

    Paresh

  3. #3
    Join Date
    Mar 2003
    Posts
    3
    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/247referenc.../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

  4. #4
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    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

  5. #5
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    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

  6. #6
    Join Date
    Mar 2003
    Posts
    3
    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

  7. #7
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured