C#DLL不公开方法

时间:2014-03-11 17:04:19

标签: c# class dll

我正在使用一个我没有创建的C#项目。我把它剥了下来。

我以为我做的都很正确。它编译得很好,我可以在e中引用DLL。 G。一个VB.NET应用程序并使用它。

但是,DLL的方法不会暴露。

有人可以告诉我他是否立刻出现了问题?

这是DLL的重要部分,我想:

using System;
using System.Collections;
using System.Data;
using System.Reflection;
using System.Text;
using SevenZip.Compression.LZMA;

namespace SevenZipControl
{
    public static class Zipper
    {
        public static bool compressBytes(byte[] InputBytes,out byte[] OutputBytes)
        {
            OutputBytes=SevenZipHelper.Compress(InputBytes);
            return true;
        }
        public static bool decompressBytes(byte[] InputBytes, out byte[] OutputBytes)
        {
            OutputBytes = SevenZipHelper.Decompress(InputBytes);
            return true;
        }
    }
}

这就是我在VB.NET中使用它的方法:

    Dim c As SevenZipControl.Zipper
    c. (...) 

但我的功能" compressBytes"和" decompressBytes"在这个截图中看不到:

enter image description here

2 个答案:

答案 0 :(得分:4)

您的代码列出了静态方法。您正在创建SevenZipControl.Zipper类的实例。

答案 1 :(得分:2)

为了搭载@ JAnderson的答案,您不需要使用Dim进行实例化。以下应该有效:

SevenZipControl.Zipper.compressBytes(data)

有关静态类概念如何转换为VB的一些信息,请参阅this discussion