简体   繁体   English

从 c# 调用 VB.Net function

[英]Calling VB.Net function from c#

I've a vb.net class library and my c# application is accessing that method.我有一个 vb.net class 库,我的 c# 应用程序正在访问该方法。 My C# code gives me compile time error that 'Start' is not supported by language, where Start is my method name.我的 C# 代码给了我编译时错误,即语言不支持“开始”,其中“开始”是我的方法名称。

Signature of Start method is Start 方法的签名是

Public Sub Start(Byval frm as Form,
                 ByVal db as DBAccess,
                 ByVal roleID as integer)

where DBAccess is a userDefined class其中 DBAccess 是用户定义的 class

and my c# calling code is我的 c# 调用代码是

obj.Start(frm, db, roleID);

Thanks谢谢

According to this , this error can be caused by optional parameters in VB.net declaration or not-supported types in C#. 据此,此错误可能是由 VB.net 声明中的可选参数或 C# 中不支持的类型引起的。
May be you should just recompile your vb.net library and re-add reference to your c# project.也许您应该重新编译您的 vb.net 库并重新添加对您的 c# 项目的引用。
But I think you should change your method definition to such:但我认为您应该将方法定义更改为:

Public Sub Start(Byval frm as Form, ByVal db as DBAccess, ByVal roleID as Int32)

type of roleID is changed from Integer to Int32 . roleID 的类型从Integer更改为Int32

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM