为什么在C#中加载.NET VB DLL中的属性会丢失? [英] Why would a property in .NET VB DLL be missing when loaded in C#?

查看:37
本文介绍了为什么在C#中加载.NET VB DLL中的属性会丢失?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过示例项目中制造商提供的.NET VB DLL与C#中的仪器控制器通信。 VB代码完美无缺。当我附加DLL作为我的C#项目的引用时,缺少一个键属性。所有其他属性和方法都按预期显示。确实出现的方法在C#项目中起作用。在VB对象浏览器中,属性定义如下:



I am trying to talk to an instrument controller in C# through a .NET VB DLL provided by the manufacturer in an example project. The VB code works flawlessly. When I attach the DLL as a reference to my C# project a key property is missing. All the other properties and methods appear as expected. The methods that do appear work in the C# project. In the VB Object Browser the property is defined as follows:

ModbusTransaction‎(Byte‎) As Object



引用代码:




which references the code:

Public ReadOnly Property ModbusTransaction(ByVal CommandType As Byte)
    Get
        Call _ModbusTransaction(CommandType)
        Return _TransactionSuccess
    End Get
End Property





此属性用作示例代码中的方法,所以我不知道为什么它没有这样声明。我的问题是我无法执行此操作或知道如何从C#中找到它。我使用的是VS 2013,如果它有所作为。



感谢您的帮助,

SMW



我尝试了什么:



我在C#项目中尝试过DLL的方法和那些不要求缺少的属性(方法)正常工作。



This property is used as a method in the example code so I do not know why it is not declared as such. My problem is that I cannot execute this or know how to find it from C#. I am using VS 2013 if that makes a difference.

Thanks for any help,
SMW

What I have tried:

I have tried methods from the DLL in my C# project and the ones that do not require the missing property (method) work properly.

推荐答案

你没有给VB属性代码一个返回类型。

You didn't give the VB Property code a return type.
Public ReadOnly Property ModbusTransaction(ByVal CommandType As Byte) As ????
    Get
        _ModbusTransaction(CommandType)
        Return _TransactionSucess           '<----Where is this value coming from?
   End Get





或者该物业真的应该是一个功能吗?



Or should that property really be a Function??

Public Function ModbusTransaction(ByVal CommandType As Byte) As ????
    return _ModbusTransaction(CommandType)
End Function


这篇关于为什么在C#中加载.NET VB DLL中的属性会丢失?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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