Results 1 to 2 of 2

Thread: [2005] COM Interop

  1. #1

    Thread Starter
    Fanatic Member clarkgriswald's Avatar
    Join Date
    Feb 2000
    Location
    USA
    Posts
    799

    Exclamation [2005] COM Interop

    I have a COM DLL that has a property of type Object. In .NET, I try and set the property to an instance of a COM Visible .NET class, but keep getting an invalid cast exception. I have tried several different methods of passing the class, but can't get it to work. For example, I have tried the following:

    Example 1
    VB Code:
    1. Dim _myObject as Object = New clsTest
    2.  
    3. _comObject.ObjectProp = _myObject
    Example 2
    VB Code:
    1. Dim _myObject as New clsTest
    2.  
    3. _comObject.ObjectProp = _myObject
    Example 3
    VB Code:
    1. Dim _myObject as New clsTest
    2.  
    3. _comObject.ObjectProp = CType(_myObject, Object)
    4. _comObject.ObjectProp = DirectCast(_myObject, Object)

    None of those work, but if I set _myObject = New TextBox, for example, it DOES work. The COM property's Let routine accepts the Object parameter ByRef.

    Any ideas?

  2. #2

    Thread Starter
    Fanatic Member clarkgriswald's Avatar
    Join Date
    Feb 2000
    Location
    USA
    Posts
    799

    Re: [2005] COM Interop

    Bump...lil' help

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