Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: VB7
Expertise: Intermediate
Dec 15, 2003

LoadAssembly - Loading an assembly identified by the path or the partial name

' Load an assembly identified by the path or the partial name
' Note: requires Imports System.Reflection
' 
' Examples:
'   1) Dim asm As [Assembly] = LoadAssembly("System.Web")
'   2) Dim asm As [Assembly] = LoadAssembly("C:\MyApp\MyAssembly.dll") 

Function LoadAssembly(ByVal asmFile As String) As [Assembly]
    Dim asm As [Assembly]
    Try
        ' attempt to load the assembly from a path
        asm = [Assembly].LoadFile(asmFile)
    Catch ex As Exception ' ignore exceptions
    End Try

    Try
        ' attempt to load an assembly with this (partial) name
        If asm Is Nothing Then
            asm = [Assembly].LoadWithPartialName(asmFile)
        End If
    Catch ex As Exception ' ignore exceptions
    End Try

    ' return whatever we have found so far
    Return asm
End Function
Francesco Balena
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap