Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 16th, 2005, 01:16 AM
Registered User
 
Join Date: Jul 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Srikanth_nd Send a message via Yahoo to Srikanth_nd
Default CreateInstance method problem(urgent)..

hi friends,

            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

Try

'Here append the class name with the component name.

Dim sbTypeName As StringBuilder = New StringBuilder("")

sbTypeName.Append(strComponentName)

sbTypeName.Append(".")

sbTypeName.Append(strclassName)

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)

Return objReturn

Catch ex As Exception

Throw New Exception(String.Format("Component Error", ex.Message))

End Try

End Function

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

using testApp;

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

srikanth








Similar Threads
Thread Thread Starter Forum Replies Last Post
How to call DLL Method in Javascritp? URGENT!!!!!! prabhakar123 Javascript 26 November 28th, 2011 07:06 AM
Urgent Help Needed : InvalidateControl Method vikasbhandari2 .NET Framework 3.5 0 June 11th, 2008 09:38 AM
Problem with Activator.CreateInstance karveajit .NET Framework 1.x 0 May 11th, 2006 01:05 AM
Stackoverflow error in recursive method (URGENT... sangi Java Espanol 0 March 27th, 2005 05:53 AM
getrows method-urgent????? mikedeepak Classic ASP Databases 6 September 1st, 2004 03:36 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.