P
Paul Hatcher
Hi
I'm trying to create an instance of an object that's in one of the System
assemblies; this code works fine for classes in my application, but fails
when the assembly is not in the application directory, e.g when it's in the
GAC.
Private Function Create(ByVal className As String) As Object
Dim handle As System.Runtime.Remoting.ObjectHandle
' Now create it
Try
handle = Activator.CreateInstance(AssemblyName, Me.Namespace + "."
+ ClassPrefix + className)
' Unwrap the object and return it
Return CType(handle.Unwrap, Object)
Catch ex As Exception
Throw New Exception("Error occured creating class from " +
Me.Namespace + "." + className + " in " + AssemblyName + " - " +
ex.ToString, ex)
End Try
End Function
Any ideas how to work around this?
Paul
I'm trying to create an instance of an object that's in one of the System
assemblies; this code works fine for classes in my application, but fails
when the assembly is not in the application directory, e.g when it's in the
GAC.
Private Function Create(ByVal className As String) As Object
Dim handle As System.Runtime.Remoting.ObjectHandle
' Now create it
Try
handle = Activator.CreateInstance(AssemblyName, Me.Namespace + "."
+ ClassPrefix + className)
' Unwrap the object and return it
Return CType(handle.Unwrap, Object)
Catch ex As Exception
Throw New Exception("Error occured creating class from " +
Me.Namespace + "." + className + " in " + AssemblyName + " - " +
ex.ToString, ex)
End Try
End Function
Any ideas how to work around this?
Paul