Skip to main content
August 5, 2013
Question

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

  • August 5, 2013
  • 0 replies
  • 1199 views

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
  HResult=-2147467262
  Message=Return argument has an invalid type.
  Source=mscorlib
  StackTrace:
       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!

This topic has been closed for replies.