AnsweredAssumed Answered

PropertyManagerPage in VSTA 3 C# Macro

Question asked by Alexandre Gragnano on Sep 11, 2020
Latest reply on Sep 11, 2020 by Alexandre Gragnano

Hello everyone,

 

I am currently experiencing a problem.

When I create a property manager page from a VSTA3 C# macro, an exception is thrown:

 

System.InvalidCastException was unhandled by user code
    HResult=-2147467262
    Message=Le cast spécifié n'est pas valide.
    Source=mscorlib
    StackTrace:
        à System.StubHelpers.InterfaceMarshaler.ConvertToNative(Object objSrc, IntPtr itfMT, IntPtr classMT, Int32 flags)
        à SolidWorks.Interop.sldworks.ISldWorks.CreatePropertyManagerPage(String Title, Int32 Options, Object Handler, Int32& Errors)
        à Peigne.PrpMgrPage..ctor(SldWorks swApp) dans c:\...\PrpMgrPage.cs:ligne 24
        à Peigne.SolidWorksMacro.Main() dans c:\...\SolidWorksMacro.cs:ligne 16
        à Peigne.SolidWorksMacro.Execute(String strDebug) dans c:\...\SolidWorksMacroStartup.cs:ligne 21
    InnerException:

        (null)

SldWorks::CreatePropertyManager arguments seems valid (type and value) but an InvalidCastException is thrown.

Any idea to solve this problem ?

 

Regards

 

Edit:

The InvalidCastException does not concern the PropertyManagerPage2 cast.

The exception is thrown on SldWorks::CreatePropertyManager statement:

 

Outcomes