ProxyGen failure on generating descriptor file from a TLB

Last post 01-22-2007, 6:30 PM by Gary. 2 replies.
Sort Posts: Previous Next
  •  12-28-2006, 3:01 PM 215

    ProxyGen failure on generating descriptor file from a TLB

    We have a few related products based off the same code base which have VBA integrated in it. We have split our object models into a few pieces, so that each product has two type libraries - common and app-specific. The common type library is the same for each product, while app-specific one has the methods/classes specific to that product. This way, we can have a plug-in created that would work with all the products (using their common functionality by referencing the common type library) as well as product-specific plug-ins that would use the app type library.

    Now we are trying to see what would it take to integrate VSTA into our products. However we have a problem right at the stage of generating the proxy. Trying to run ProxyGen with command line like this:

    proxygen.exe /l:"app.tlb" /c:"proxy.cs" /o:"descriptor.xml"

    produces the following error:

    An unrecoverable error was encountered during processing.
    Object reference not set to an instance of an object.
    This may have been caused by earlier errors.

    There is something generated in descriptor.xml but it doesn't have all the types declared in the type library.

    Just to give you some more background info on our type library structure. As I said earlier, each product has two type libraries: "common.tlb" and "app.tlb"

    Common tlb has just the common interfaces of features available to all application SKUs based on the product platform.

    e.g.

    library CoreLib
    {
    [uuid(...)]
    interface ICoreApplication : IDispatch
    {
       HRESULT Visible([in] VARIANT_BOOL newVal);
    }
    }

    The application type library includes the core interfaces as well as defines application-specific classes and methods:

    library AppLib
    {
    importlib "common.tlb"

    [uuid(...)]
    interafce IApplication : IDispatch
    {
       HRESULT Visible([in] VARIANT_BOOL newVal);
       HRESULT SomeAppSpecificMethod();
    }

    [appobject, uuid(...)]
    coclass Application
    {
       [default] interface IApplication;
       interface ICoreApplication;
    }
    }

    So, when a plugin is created it can either choose to use IApplication interface to use all the features of the particular product, or ICoreApplication which is shared between all the products, making the plug-in work with any product based off the code platform.

    I have both app.tlb and common.tlb registered on the dev machine, yet I have this error occuring which prevents us from further investigating VSTA integration...

    Any suggestions?

  •  01-02-2007, 9:57 AM 216 in reply to 215

    Re: ProxyGen failure on generating descriptor file from a TLB

    We have reported similar proxygen bugs to the VSTA team.  They have confirmed these and are planning a interim release of proxygen with bug fixes (date unannounced).

    If you will supply us with the type library files (ideally include the .idl source), we will reproduce the error and submit a bug report to the VSTA team.

    In the mean time, you should try reducing the content of your type library until the cause of the error is determined.  By doing this, you will probably find that there is a clear and reasonable workaround.  Also, by setting the IsExcluded='true' attribute for portions of your object model as described in the XML descriptor file, you may be able to use the descriptior file as input and remove the offending/unwanted portions of your type library from proxygen's consideration: 

    proxygen.exe /l:"app.tlb" /c:"proxy.cs" /i:"descriptor.xml"

  •  01-22-2007, 6:30 PM 239 in reply to 216

    Re: ProxyGen failure on generating descriptor file from a TLB

    Hi Alex,

    Regarding this error:

    "An unrecoverable error was encountered during processing.

    Object reference not set to an instance of an object.

    This may have been caused by earlier errors."

    The proxy problems can be bypassed by creating  a small proxy layer that will pass an IDispatch of your application object through the proxy.  The addin project would set a direct reference to the PIA of your COM object and cast the incoming 'Object' to the strong type.  This can be accomplished in the startup code with no added complexity for the Addin author.

    This approach is a workaround endorsed by Microsoft available from our ftp site (see lnk below).  It uses IInteropObjectContract to bypass the MAF proxy, exposing the COM object to the addin.  

    This is a modified ShapeAppBasicMFC.zip sample, which includes a method named CreateExcelInstance() that returns the IDispatch of an Excel application

    ftp://ftp.summsoft.com/private/ShapeAppBasicMFC-outofprocReadme.doc

    ftp://ftp.summsoft.com/private/ShapeAppBasicMFC-outofprocV2.zip

    In a similiar way, you can create a minimal proxy that passes the IDispatch of any COM object in your OM.

    Let me know if you have any questions regarding this workaround, etc...

    Regards,

    Gary

View as RSS news feed in XML