通过COM互操作将字节数组从C#返回到VBScript [英] Return byte array from C# to VBScript via COM interop

查看:95
本文介绍了通过COM互操作将字节数组从C#返回到VBScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有C#方法,该方法返回一个我希望能够从VBScript访问的字节数组。或多或少:

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 };
        }
     }
 }

和vbscript看起来像:

and the vbscript to look like:

dim o
dim b

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

o.Create b

MsgBox ubound(b)

我迷路了。 Google不想合作...我希望这里有人可以提供帮助!

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

Rob

推荐答案

这应该有所帮助:

COM Interop第2部分:C#服务器教程

http://msdn.microsoft.com/zh-CN/library/aa645738( VS.71).aspx

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

这:

使用.NET创建COM服务器。 C#

http: //codebetter.com/blogs/peter.van.ooijen/archive/2005/08/02/130157.aspx

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

这篇关于通过COM互操作将字节数组从C#返回到VBScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆