none
Class doesn't support automation (script -> managed code) RRS feed

  • Question

  • Hi - summary of setup:

     

    managed C++ application with html view.  HTML contains script which uses window.external to get hold of business objects which are written in VB.Net.

     

    This all works fine - i can invoke methods in the VB.Net business objects from the javascript.  However some of my method calls try to pass parameters to the managed code & i'm running into interop problems.

     

    e.g.

     

    var oParam1= window.external.Param1

    var oParam2= window.external.Param2

    var sMenuHTML = oBO.MenuHTML(oParam1, oParam2);

     

    with the VB.Net method being

     

    Public ReadOnly Property MenuHTML(ByVal oParam1 As Type1, ByVal oParam2 As Type2) As String

     

    When this method is called i get a 'Class doesn't support automation' error which i figure is to do with marshalling the types / COM issues?

     

    I've tried all sorts of marshalling options & various attributes (like 

    <Assembly: ClassInterface(ClassInterfaceType.AutoDispatch)>

     

    but nothing works.

     

    Any help would be really, really appreciated.  Cheers.

    Monday, April 21, 2008 11:36 AM

Answers

  • Declare the arguments of MenuHTML "As Object".  You'll have to cast them to the type you need.  Although VB.NET with Option Strict Off allows you to use variables of type Object as-is.
    Tuesday, April 22, 2008 12:01 AM
    Moderator

All replies

  • Declare the arguments of MenuHTML "As Object".  You'll have to cast them to the type you need.  Although VB.NET with Option Strict Off allows you to use variables of type Object as-is.
    Tuesday, April 22, 2008 12:01 AM
    Moderator
  • Thanks for your reply - i actually tried that last night but now get a different error:

     

    Object reference not set to an instance of an object.

     

    the objects used are checked for null - i.e

     

    var oCompany = window.external.Company

    if (oCompany == null)

    {

    return;

    }

    var oP1 = window.external.P1

    var oP2 = window.external.P2

     

    if (oP1 == null || oP2 == null)

    {

    return;

    }

     

    oCompany.MenuHTML(oP1, oP2);

    Tuesday, April 22, 2008 2:51 PM