Workaround for the same namespace defined in two assemblies using VB.NET

The iTextSharp compilation includes the BouncyCastle namespace in the main assembly, but the VB.Net application I am working with is already using a different version of BouncyCastle. I think C # can get around this by using "extern alias", but I can't seem to find how to do this in VB.NET.

Is there an equivalent to extern alias in VB.Net, or any other way to exclude specific namespaces from a specific assembly?

+3


source to share


1 answer


You can alias your namespaces in import like this:

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

      

See MSDN link for full details: http://msdn.microsoft.com/en-us/library/7f38zh8x.aspx

+1


source







All Articles