通过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