从C#.Net 2010开始推出VB6功能 [英] Pinvoke a VB6 function from C#.Net 2010

查看:116
本文介绍了从C#.Net 2010开始推出VB6功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从C#PInvoke用VB6编写的函数。调用DLL的VB6代码声明如下:

I want to PInvoke a function written in VB6 from C#. The VB6 code that calls the DLL is declared like this:

Declare Function ApplyNNet Lib " location of the DLL file" (MyNNetType As String, MyAddress As String, MyInput() As Double) As Variant





My C#版本如下所示: *



My C# version looks like this:*

[DllImport("NNetApply.dll")] 
public static extern object ApplyNNet(string type, string add, double[] data);



我这样称呼函数:


I call the function like this:

object P_ = ApplyNNet("Back Prop", address,data);



使用此声明我收到PInvoke错误:


With this declaration I receive a PInvoke error:

PInvoke restriction: cannot return variants.

推荐答案

首先,如果你有VB6代码调用这个.DLL,你为什么要调用C#的VB6代码?绕过VB6代码直接进入.DLL!



其次,你不能调用返回Variant的VB6函数。 .NET中没有等效类型。您必须声明要返回的实际类型。
First, if you''ve got the VB6 code calling this .DLL, why are you calling the VB6 code from C#?? Just bypass the VB6 code and go straight to the .DLL!

Second, You can''t call a VB6 function that returns Variant. There is no equivilent type in .NET. You have to declare the actual type being returned.


这篇关于从C#.Net 2010开始推出VB6功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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