使用VB.NET在两个程序集中定义的相同命名空间的解决方法

时间:2014-11-17 11:27:53

标签: vb.net namespaces itextsharp

iTextSharp程序集在核心程序集中包含BouncyCastle名称空间,但我正在使用的VB.Net应用程序已经使用了不同版本的BouncyCastle。我认为C#可以通过使用" extern别名"来解决这个问题。但我无法在VB.NET中找到如何做到这一点。

VB.Net中是否有任何等效的外部别名或以任何其他方式从特定程序集中排除特定名称空间?

1 个答案:

答案 0 :(得分:1)

您可以在导入中为命名空间设置别名,如下所示:

Imports [ aliasname = ] namespace
-or-
Imports [ aliasname = ] namespace.element

IE

Imports strbld = System.Text.StringBuilder
Imports dirinf = System.IO.DirectoryInfo

Public Function GetFolders() As String 
    Dim sb As New strbld

    Dim dInfo As New dirinf("c:\")
    For Each dir As dirinf In dInfo.GetDirectories()
        sb.Append(dir.Name)
        sb.Append(ControlChars.CrLf)
    Next 

    Return sb.ToString
End Function

有关完整信息,请参阅MSDN参考:http://msdn.microsoft.com/en-us/library/7f38zh8x.aspx