Return byte array from C# to VBScript via COM interop

可紊 提交于 2019-12-24 08:57:22

问题


I have C# method that returns a byte array I want to be able to access from VBScript. More or less:

namespace ClassLibrary7
{
    [ClassInterface(ClassInterfaceType.AutoDual)]
    [Guid("63A77D29-DB8C-4733-91B6-3CC9C2D1340E")]
    [ComVisible(true)]
    public class Class1
    {
        public void Create(
            out byte[] BinaryData
            )
        {
            // do some work and return BinaryData
            BinaryData = new byte[] { 1, 2, 3, 4 };
        }
     }
 }

and the vbscript to look like:

dim o
dim b

set o = wscript.CreateObject("ClassLibrary7.Class1")

o.Create b

MsgBox ubound(b)

I'm lost. Google doesn't want to cooperate... and I'm hoping someone here can help!

Rob


回答1:


This should help:

COM Interop Part 2: C# Server Tutorial
http://msdn.microsoft.com/en-us/library/aa645738(VS.71).aspx

and this:

Creating a COM server with .NET. C#
http://codebetter.com/blogs/peter.van.ooijen/archive/2005/08/02/130157.aspx



来源:https://stackoverflow.com/questions/978861/return-byte-array-from-c-sharp-to-vbscript-via-com-interop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!