0 Replies Latest reply on Aug 4, 2013 8:45 PM by MMMM4_wang

    InvalidCastException occurred. Return argument has an invalid type in illustrator cs5 VB in VS2012.


      I am writthing a simple illustrator CS5 VB application for testing in VS2012 on Windows7 64-bit. The application can be built succesfully, but got an error at line 2- InvalidCastException occurred. Return argument has an invalid type.

      line 1 - Dim  appref As Illustrator.Application = New Illustrator.Application

      line 2 - Dim myDoc As Illustrator.Document = appref.ActiveDocument

      The detailed errror is


      System.InvalidCastException occurred
        Message=Return argument has an invalid type.
             at System.Runtime.Remoting.Proxies.RealProxy.ValidateReturnArg(Object arg, Type paramType)
             at System.Runtime.Remoting.Proxies.RealProxy.PropagateOutParameters(IMessage msg, Object[] outArgs, Object returnValue)...................

      But similar code works in word 2007 macro, so reference to  illustrator CS5 is fine. I think it is caused by .NET Framework 4. Where should I start to solve the problem? Any help is appreciated. Thanks!