locked
COM interop "ByRef value type parameter cannot be null"

    Question

  • MDSN World,

    My first post...  Guess that can be taken as good or bad Smile

     

    So.. I am using a tlb as an interop reference in a VB.Net project that works perfectly fine except for in one property and two of its methods. Other than is one, i am use about 20 or 30 other methods that work just fine.

     

    code:

     

    Try

    oPSMessageCollection.DeleteAll()

    Catch ex As Exception

    MsgBox(ex.Message)

    End Try

     

    the ex.message comes back with

    "ByRef value type parameter cannot be null"

     

    the deleteall method doesn't except parameters and it is meant to return a boolean.

     I am thinking it is an issue with the interop data type conversion because when I use the OLEviewer the data type is variant_bool, a 2 byte value, and i know that vb.net boolean is 4 byte value, could this be it? if so, can i marshal the response? angain, if so how?

     

    Any ideas would get of great help, my wall is getting sore from my head hitting it too often.. Smile

     

    Thanks!

     

    Tim

    Wednesday, July 18, 2007 4:46 PM

Answers

  • Few things.

     

    1) You may try using late-binding.

    e.g.

    dim o as object = oPSMessageCollection

    o.DeleteAll

     

    That might work for you

     

    2) If not, then when you run oleviewer, copy and paste the actual idl description of the deleteall method into this post and that might help figure out what is going wrong. 

     

    Toddap_MS

    Friday, July 20, 2007 4:04 PM

All replies

  • Few things.

     

    1) You may try using late-binding.

    e.g.

    dim o as object = oPSMessageCollection

    o.DeleteAll

     

    That might work for you

     

    2) If not, then when you run oleviewer, copy and paste the actual idl description of the deleteall method into this post and that might help figure out what is going wrong. 

     

    Toddap_MS

    Friday, July 20, 2007 4:04 PM
  • The Late binding tip seems to have done it! Thanks so much!

     

    Tuesday, August 14, 2007 9:45 PM