VB.Net
Imports System.Reflection.Assembly
Public ReadOnly property MyAssembly as Assembly
Get
dim assy as assembly = nothing
dim assypath as string = "C:\yourfilepath.dll"
dim assyfullname as string = "MyAssemblyName,Version = 1.0.0.0" + _
"Culture = neutral,PublicKeyToken = ba0014rg1234809"
dim assypartialname as string = "MyAssemblyPartialName"
'If you know the path from where to load the assembly
assy = LoadFile(assypath)
'If you want to load the executing assembly
assy = GetExecutingAssembly()
'If you want to load the assembly that started the process
assy = GetEntryAssembly()
'If you want to load the assembly from one level up in the stack
assy = GetCallingAssembly()
'If you want to load the assembly from GAC,however in .Net 2.0 this method has become obsolete but you can still use it.
assy = LoadWithPartialName(assypartialname)
'If you want to load the assembly only for interoggation but not for creating instance
assy = ReflectionOnlyLoad(assyfullname)
Or
assy = ReflectionOnlyLoadFrom(assypath)
return assy
End Get
I have mainly used LoadWithPartialName,GetExecutingAssembly
I have mainly used LoadWithPartialName,GetExecutingAssembly
No comments:
Post a Comment