C#和VBA的互操作性 [英] C# and VBA interoperability

查看:96
本文介绍了C#和VBA的互操作性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我需要构建一个C#dll并从VBA调用它.我已经在一个简单的示例中使用返回字符串的方法对其进行了测试.但是,如何返回更复杂的对象?例如,我的方法将返回C#专有的二叉树.如何将其转换为VBA?

预先感谢,
标记

Hello everyone,

I need to build a C# dll and to call it from VBA. I''ve tested it on a simple example with a method that returns strings. But how can I return more complex objects? For instance, my method will return a C# proprietary binary tree. How will it be converted to VBA?

Thanks in advance,
Mark

推荐答案

因此,基本上,您希望C#dll填充一个二进制树,然后可以从VBA进行查询.
您可能必须实现诸如Load,First,Next,Count等方法,并从VBA中使用它们来从DLL中获取数据.我认为您不能在VBA中大量使用C#专有的二叉树,但不久之后我可能会得到纠正.

您可能会从此答案中得到一些提示.
以编程方式从vba应用安装和引用.net dll [ ^ ]
您基本上必须创建一个COM dll.过去,使用.NET尝试这样做有很多问题-我不得不在Delphi中制作我的dll,因为它可以正常工作而没有任何麻烦.
So basically you want your C# dll to populate a binary tree that you can then interrogate from VBA.
You will probably have to implement methods such as Load, First, Next, Count etc. and use them from VBA to get the data out of the DLL. I don''t think you can use a C# proprietary binary tree for much in VBA, but I will probably stand corrected shortly.

You may get some hints from this answer.
installing and Refereing .net dll programmatically from vba app[^]
You''ve basically got to create a COM dll. I''ve had various issues trying to do so with .NET in the past - and I''ve resorted to make my dll in Delp because it just worked without any of the hoops.


这篇关于C#和VBA的互操作性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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