<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Passing Late-bound Variant arrays to AutoCAD in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/passing-late-bound-variant-arrays-to-autocad/m-p/3603728#M53673</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To let everyone know how this ended up and what I learned:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2" color="#008000"&gt;&lt;FONT face="Consolas" size="2" color="#008000"&gt;&lt;FONT face="Consolas" size="2" color="#008000"&gt;'marshals correctly when using Interop.AutoCAD.dll&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt; plt &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;As &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;AutoCAD.AcadPlot = Layout.Document.Plot&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;plt.SetLayoutsToPlot(layoutarr)&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2" color="#008000"&gt;&lt;FONT face="Consolas" size="2" color="#008000"&gt;&lt;FONT face="Consolas" size="2" color="#008000"&gt;'does not work without Interop.AutoCAD.dll&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt; plt &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;As &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;Object&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;= Layout.Document.Plot&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;doc.Plot.SetLayoutsToPlot(layoutarr)&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2" color="#008000"&gt;&lt;FONT face="Consolas" size="2" color="#008000"&gt;&lt;FONT face="Consolas" size="2" color="#008000"&gt;'this works with no interop .dll&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt; plt &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;As &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;Object&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;= Layout.Document.Plot&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;plt.SetLayoutsToPlot(MarshalVariantStringArray(layoutarr))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Public &lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;Function&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt; MarshalVariantStringArray(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;ByVal&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt; ObjIn &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;Object&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;) _&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt; &amp;lt;Runtime.InteropServices.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#2b91af"&gt;&lt;FONT face="Consolas" size="2" color="#2b91af"&gt;&lt;FONT face="Consolas" size="2" color="#2b91af"&gt;MarshalAsAttribute&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;( _&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Runtime.InteropServices.&lt;FONT face="Consolas" size="2" color="#2b91af"&gt;&lt;FONT face="Consolas" size="2" color="#2b91af"&gt;&lt;FONT face="Consolas" size="2" color="#2b91af"&gt;UnmanagedType&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;.SafeArray, _&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SafeArraySubType:=Runtime.InteropServices.&lt;FONT face="Consolas" size="2" color="#2b91af"&gt;&lt;FONT face="Consolas" size="2" color="#2b91af"&gt;&lt;FONT face="Consolas" size="2" color="#2b91af"&gt;VarEnum&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;.VT_BSTR)&amp;gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;Object&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;Return&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;ObjIn&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;End &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;Function&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In summary, VB is using the type information in the Interop.AutoCAD.dll to know how to marshal the string array into a variant.&amp;nbsp; In the absence of that information, the default marshalling does not take care of it, but you can use attributes to tell the compiler what you are really trying to do.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also for reasons that I do not really understand, the VariantWrapper object did not help the situation. AutoCAD still saw that as an invalid parameter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe this will help other lunatics like me that have an ongoing vested interest in using late binding.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mike Leslie&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 31 Aug 2012 19:54:38 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2012-08-31T19:54:38Z</dc:date>
    <item>
      <title>Passing Late-bound Variant arrays to AutoCAD</title>
      <link>https://forums.autodesk.com/t5/net-forum/passing-late-bound-variant-arrays-to-autocad/m-p/3591720#M53671</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;I have been attempting to pass a string array contained in a variant to the AutoCAD method AcadPlot.SetLayoutsToPlot.&amp;nbsp; I am using late binding without a Interop assembly because we have several versions of AutoCAD in this company and I would like to support all of them from the same code base.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;The method wants a variant that contains a string array passed byref.&amp;nbsp; The Microsoft documentation on COM interop from VB.NET makes it sound like the compiler will marshal it correctly by default, but it always throws a COMException (Exception from HRESULT: 0x80070057 (E_INVALIDARG)).&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;The stack trace shows it is trying to anyway:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;StackTrace:&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack, Boolean IgnoreReturn)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateCall(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, Boolean IgnoreReturn)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;But no matter how I code it I cannot get this variant array passed to AutoCAD.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;I have tried:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Imports System.Runtime.InteropServices&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;' VB default marshalling&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;Dim layoutarr = New Object() {"Layout1"}&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;doc.Plot.SetLayoutsToPlot(layoutarr)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;' using a VariantWrapper&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;Dim layoutarr = New Object() {"Layout1"}&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;Dim wrapper As New System.Runtime.InteropServices.VariantWrapper(layoutarr)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;doc.Plot.SetLayoutsToPlot(wrapper)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;'making a method and using a custom marshaling attribute&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Dim layoutarr = New Object() {"Layout1"}&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;doc.Plot.SetLayoutsToPlot(MarshalVariantStringArray(layoutarr))&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Public Function MarshalVariantStringArray(ByVal ObjIn As Object) As &amp;lt;MarshalAsAttribute(UnmanagedType.SafeArray, SafeArraySubType:=VarEnum.VT_BSTR)&amp;gt; Object&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Return ObjIn&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;End Function&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;'using reflection to invoke the method&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;'(not sure why that would help, but it was worth a try)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Dim layoutarr = New Object() {"Layout1"}&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;Dim argarr(0 To 0) As Object&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;argarr(0) = layoutarr&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;doc.Plot.GetType().InvokeMember("SetLayoutsToPlot", Reflection.BindingFlags.InvokeMethod, Nothing, doc.Plot, argarr)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Does anyone know what to do in this situation?&amp;nbsp; As intensively as AutoCAD ActiveX uses variant arrays, I know this problem is going to come up again and again for me as I try to migrate code over to .NET.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Thanks.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2012 20:42:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/passing-late-bound-variant-arrays-to-autocad/m-p/3591720#M53671</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-08-22T20:42:57Z</dc:date>
    </item>
    <item>
      <title>Re: Passing Late-bound Variant arrays to AutoCAD</title>
      <link>https://forums.autodesk.com/t5/net-forum/passing-late-bound-variant-arrays-to-autocad/m-p/3593140#M53672</link>
      <description>&lt;P&gt;I think in your all attempts you did the same thing: trying to pass an ARRAY of object, instead of required AN object that is an array of string.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is how crapy VB.NET tries to to more things behind of scene for user. If you set Option Strict on, the error would have been caught at compiling time:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim something = New Object() {...}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is equivalent to&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim&amp;nbsp;layoutarr As object()&lt;/P&gt;&lt;P&gt;layoutarr=New Object(){...}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hence the error: object array with one element is not the same as a single object&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;While in your cose you should have done this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim&amp;nbsp;layoutarr&amp;nbsp;As object=new String(){....}&lt;/P&gt;&lt;P&gt;I think even this might work"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim layoutarr As String()=New String(){...}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Personally, if I have to write with VB.NET, I never omit the As part in the Dim statement, just make the declaration code unmistakenly clear. Whether Option Strict is on or not&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you use C#, you would not have run into this type of mistake.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Aug 2012 16:40:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/passing-late-bound-variant-arrays-to-autocad/m-p/3593140#M53672</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2012-08-23T16:40:04Z</dc:date>
    </item>
    <item>
      <title>Re: Passing Late-bound Variant arrays to AutoCAD</title>
      <link>https://forums.autodesk.com/t5/net-forum/passing-late-bound-variant-arrays-to-autocad/m-p/3603728#M53673</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To let everyone know how this ended up and what I learned:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2" color="#008000"&gt;&lt;FONT face="Consolas" size="2" color="#008000"&gt;&lt;FONT face="Consolas" size="2" color="#008000"&gt;'marshals correctly when using Interop.AutoCAD.dll&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt; plt &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;As &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;AutoCAD.AcadPlot = Layout.Document.Plot&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;plt.SetLayoutsToPlot(layoutarr)&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2" color="#008000"&gt;&lt;FONT face="Consolas" size="2" color="#008000"&gt;&lt;FONT face="Consolas" size="2" color="#008000"&gt;'does not work without Interop.AutoCAD.dll&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt; plt &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;As &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;Object&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;= Layout.Document.Plot&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;doc.Plot.SetLayoutsToPlot(layoutarr)&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2" color="#008000"&gt;&lt;FONT face="Consolas" size="2" color="#008000"&gt;&lt;FONT face="Consolas" size="2" color="#008000"&gt;'this works with no interop .dll&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt; plt &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;As &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;Object&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;= Layout.Document.Plot&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;plt.SetLayoutsToPlot(MarshalVariantStringArray(layoutarr))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Public &lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;Function&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt; MarshalVariantStringArray(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;ByVal&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt; ObjIn &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;Object&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;) _&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt; &amp;lt;Runtime.InteropServices.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#2b91af"&gt;&lt;FONT face="Consolas" size="2" color="#2b91af"&gt;&lt;FONT face="Consolas" size="2" color="#2b91af"&gt;MarshalAsAttribute&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;( _&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Runtime.InteropServices.&lt;FONT face="Consolas" size="2" color="#2b91af"&gt;&lt;FONT face="Consolas" size="2" color="#2b91af"&gt;&lt;FONT face="Consolas" size="2" color="#2b91af"&gt;UnmanagedType&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;.SafeArray, _&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SafeArraySubType:=Runtime.InteropServices.&lt;FONT face="Consolas" size="2" color="#2b91af"&gt;&lt;FONT face="Consolas" size="2" color="#2b91af"&gt;&lt;FONT face="Consolas" size="2" color="#2b91af"&gt;VarEnum&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;.VT_BSTR)&amp;gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;Object&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;Return&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;ObjIn&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;End &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;&lt;FONT face="Consolas" size="2" color="#0000ff"&gt;Function&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In summary, VB is using the type information in the Interop.AutoCAD.dll to know how to marshal the string array into a variant.&amp;nbsp; In the absence of that information, the default marshalling does not take care of it, but you can use attributes to tell the compiler what you are really trying to do.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also for reasons that I do not really understand, the VariantWrapper object did not help the situation. AutoCAD still saw that as an invalid parameter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe this will help other lunatics like me that have an ongoing vested interest in using late binding.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mike Leslie&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Aug 2012 19:54:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/passing-late-bound-variant-arrays-to-autocad/m-p/3603728#M53673</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-08-31T19:54:38Z</dc:date>
    </item>
    <item>
      <title>Re: Passing Late-bound Variant arrays to AutoCAD</title>
      <link>https://forums.autodesk.com/t5/net-forum/passing-late-bound-variant-arrays-to-autocad/m-p/4373096#M53674</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Mike’s solution looked very promising. However, when I applied it for coping blocks I get “Invalid object array” error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Dim objCollection(0) As Object

objCollection(0) = SourceFile.Blocks.Item(BlockEntity.EffectiveName)

SourceFile.CopyObjects(objCollection, TargetFile.Blocks)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know of any solution for calling CopyObjects in late bind?&lt;/P&gt;&lt;P&gt;Please note that the above work in an early bind situation in which objCollection is defined as AcadBlock:&lt;/P&gt;&lt;P&gt;(Dim objCollection(0) As AcadBlock)&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2013 19:51:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/passing-late-bound-variant-arrays-to-autocad/m-p/4373096#M53674</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-08-19T19:51:21Z</dc:date>
    </item>
    <item>
      <title>Re: Passing Late-bound Variant arrays to AutoCAD</title>
      <link>https://forums.autodesk.com/t5/net-forum/passing-late-bound-variant-arrays-to-autocad/m-p/4375631#M53675</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I replicated your error (CopyObjects working correctly early bound, failing late bound), but I was not able to find a solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I could not get the MarshalAttibutes to translate this to what AutoCAD wanted.&amp;nbsp; I had thought that passing the object(s) as an IUnknown or an IDispatch inside a SafeArray made the most sense, but it just wasn't happening.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There really should be a way to do this, but I could not find it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In theory, you could use the methods in the Marshal class to manually allocate a SAFEARRAY and to put a pointer to your object into it, but that is too involved and low-level for me to mess with right now.&amp;nbsp; I've spent too much time on this maddening problem as it is!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another way to solve would be to use SendCommand to send lisp statements to do the CopyObjects for you.&amp;nbsp; See:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A target="_blank" href="http://www.theswamp.org/index.php?topic=34676.msg399205#msg399205"&gt;http://www.theswamp.org/index.php?topic=34676.msg399205#msg399205&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I bet it would work, but I hate having to use multiple languages just to get something done!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2013 17:02:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/passing-late-bound-variant-arrays-to-autocad/m-p/4375631#M53675</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-08-21T17:02:41Z</dc:date>
    </item>
    <item>
      <title>Re: Passing Late-bound Variant arrays to AutoCAD</title>
      <link>https://forums.autodesk.com/t5/net-forum/passing-late-bound-variant-arrays-to-autocad/m-p/4375668#M53676</link>
      <description>&lt;P&gt;Thanks for the efforts on this issue.&lt;/P&gt;&lt;P&gt;I also hate having to use multiple languages when simple tasks should be doable with one.&lt;/P&gt;&lt;P&gt;I’ll try the LISP suggestion. But I wonder if CopyObjects would work in C#; it would be a more elegant solution to combine VB.NET with C# or to use C# only.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2013 17:37:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/passing-late-bound-variant-arrays-to-autocad/m-p/4375668#M53676</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-08-21T17:37:42Z</dc:date>
    </item>
    <item>
      <title>Re: Passing Late-bound Variant arrays to AutoCAD</title>
      <link>https://forums.autodesk.com/t5/net-forum/passing-late-bound-variant-arrays-to-autocad/m-p/6253786#M53677</link>
      <description>Public Function MarshalVariantStringArray(ByVal ObjIn AsObject) _&lt;BR /&gt;As &amp;lt;Runtime.InteropServices.MarshalAsAttribute( _&lt;BR /&gt;Runtime.InteropServices.UnmanagedType.SafeArray, _&lt;BR /&gt;SafeArraySubType:=Runtime.InteropServices.VarEnum.VT_BSTR)&amp;gt; Object&lt;BR /&gt;&lt;BR /&gt;ReturnObjIn&lt;BR /&gt;End Function&lt;BR /&gt;&lt;BR /&gt;how to write them by c#?</description>
      <pubDate>Wed, 06 Apr 2016 06:51:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/passing-late-bound-variant-arrays-to-autocad/m-p/6253786#M53677</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-04-06T06:51:04Z</dc:date>
    </item>
    <item>
      <title>Re: Passing Late-bound Variant arrays to AutoCAD</title>
      <link>https://forums.autodesk.com/t5/net-forum/passing-late-bound-variant-arrays-to-autocad/m-p/6254697#M53678</link>
      <description>[return: Runtime.InteropServices.MarshalAsAttribute(Runtime.InteropServices.UnmanagedType.SafeArray, SafeArraySubType = Runtime.InteropServices.VarEnum.VT_BSTR)]&lt;BR /&gt;public object MarshalVariantStringArray(object ObjIn)&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;ReturnObjIn();&lt;BR /&gt;&lt;BR /&gt;}</description>
      <pubDate>Wed, 06 Apr 2016 14:45:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/passing-late-bound-variant-arrays-to-autocad/m-p/6254697#M53678</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-04-06T14:45:36Z</dc:date>
    </item>
    <item>
      <title>Re: Passing Late-bound Variant arrays to AutoCAD</title>
      <link>https://forums.autodesk.com/t5/net-forum/passing-late-bound-variant-arrays-to-autocad/m-p/6256308#M53679</link>
      <description>&lt;P&gt;i create region in late-bound. this is code, &lt;SPAN&gt;it is show " Invalid Object Array". how can i do?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[return: System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.SafeArray, SafeArraySubType = System.Runtime.InteropServices.VarEnum.VT_BSTR)]&lt;BR /&gt;public object MarshalVariantStringArray(object ObjIn)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;return ObjIn;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;private dynamic createCircleRegion&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;dynamic[] circleObj=new dynamic[1];&lt;BR /&gt;&amp;nbsp; &amp;nbsp;double[] calpt = new double[3];&lt;BR /&gt;&amp;nbsp; &amp;nbsp;calpt[0] = 0; calpt[1] = 0; calpt[2] = 0;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;circleObj[0] = AcadDoc.ModelSpace.AddCircle(cirPt, circleR);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;object[] regionObject;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;regionObject = (object [])AcadDoc.ModelSpace.AddRegion(MarshalVariantStringArray(circleObj));//this row line is problem.&lt;BR /&gt;&amp;nbsp; &amp;nbsp;dynamic profileRegionObject = (dynamic)(regionObject[0]);&lt;BR /&gt;&amp;nbsp; &amp;nbsp;circleObj[0].Delete();&lt;BR /&gt;&amp;nbsp; &amp;nbsp; return profileRegionObject;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2016 00:14:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/passing-late-bound-variant-arrays-to-autocad/m-p/6256308#M53679</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-04-07T00:14:59Z</dc:date>
    </item>
    <item>
      <title>Re: Passing Late-bound Variant arrays to AutoCAD</title>
      <link>https://forums.autodesk.com/t5/net-forum/passing-late-bound-variant-arrays-to-autocad/m-p/6256392#M53680</link>
      <description>ObjectList&lt;BR /&gt;Access: Input-only&lt;BR /&gt;&lt;BR /&gt;Type: Variant (array of Arc, Circle, Ellipse, Line, LWPolyline, Spline objects)&lt;BR /&gt;&lt;BR /&gt;The array of objects forming the closed coplanar face to be made into a region.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;This indicates that the AddRegion method expects a SAFEARRAY of AutoCAD objects, probably insisting on them being type IAcadEntity. The function that you got from me is specific to an array of strings. You will probably have to change the SafeArraySubType = System.Runtime.InteropServices.VarEnum.VT_BSTR to s different value.&lt;BR /&gt;&lt;BR /&gt;The choices for this are listed here:&lt;BR /&gt;&lt;A href="https://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshalasattribute.safearraysubtype(v=vs.110).aspx" target="_blank"&gt;https://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshalasattribute.safearraysubtype(v=vs.110).aspx&lt;/A&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 07 Apr 2016 00:49:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/passing-late-bound-variant-arrays-to-autocad/m-p/6256392#M53680</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-04-07T00:49:45Z</dc:date>
    </item>
    <item>
      <title>Re: Passing Late-bound Variant arrays to AutoCAD</title>
      <link>https://forums.autodesk.com/t5/net-forum/passing-late-bound-variant-arrays-to-autocad/m-p/6256402#M53681</link>
      <description>While the canonical explanation of how array marshaling works is here:&lt;BR /&gt;&lt;A href="https://msdn.microsoft.com/en-us/library/z6cfh6e6(v=vs.110).aspx" target="_blank"&gt;https://msdn.microsoft.com/en-us/library/z6cfh6e6(v=vs.110).aspx&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;What I think you really want is this:&lt;BR /&gt;&lt;A href="http://vault.lozanotek.com/archive/2005/09/24/3614.aspx" target="_blank"&gt;http://vault.lozanotek.com/archive/2005/09/24/3614.aspx&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Note the extra attribute,&lt;BR /&gt;[return:MarshalAs(UnmanagedType.SafeArray,&lt;BR /&gt;SafeArraySubType=VarEnum.VT_DISPATCH,&lt;BR /&gt;SafeArrayUserDefinedSubType=typeof(Person))]&lt;BR /&gt;Person[] CreatePeople (int count);</description>
      <pubDate>Thu, 07 Apr 2016 00:56:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/passing-late-bound-variant-arrays-to-autocad/m-p/6256402#M53681</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-04-07T00:56:24Z</dc:date>
    </item>
  </channel>
</rss>

