CreateInstance method problem(urgent)..
i got stuck with a problem. in my component i have one method which will create an instance of the componentname and class we passed. code is here:
Public Function CreateComponentInstance(ByVal strComponentName As String, ByVal strclassName As String) As Object
'Here append the class name with the component name.
Dim sbTypeName As StringBuilder = New StringBuilder("")
Dim sTypeName As String = sbTypeName.ToString()
'Load the Assembly and get the Type of it.
Dim objAssembly As System.Reflection.Assembly = System.Reflection.Assembly.Load(strComponentName)
Dim objType As Type = objAssembly.GetType(sTypeName)
'Pass the type to the method and get the instance.
Dim objReturn As Object = System.Activator.CreateInstance(objType)
Catch ex As Exception
Throw New Exception(String.Format("Component Error", ex.Message))
while testing this method i am getting an error. i created a class file with assembly name as testApp. and class name as testApp. then i gave the strong name for the assembly and registered in the GAC. after that i refered that component in my test web app.
then i tried to call my method like this
testApp.testApp otestApp = (testApp.testApp)mycomponentObj.CreateComponentIns tance("testApp","testApp");
i am getting an error saying file or assembly name testApp, or one of its dependencies was not found.
can any one help me out to solve the problem?...
thanks in advance