-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: Mrinal
Message 2 in Discussion

Hi Rashid ,   I think , i can help you in pointing out the issue with ur code , 
see whole problem lies with the fact that on runtime via reflection it tries to 
load the assembly after locating it in the path that you would have specified 
explicitly or using the assembly search strategy by .net framework .   In your 
case since you have not specified an exact path and installed assembly in GAC , 
so you do expect it to be found there , but few things :   1. Specify assembly 
name using the prefix ".dll" or ".exe" as the case may be . 2. Go through the 
link :     
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconhowruntimelocatesassemblies.asp
   As depending upon the method Load , LoadFrom or LoadFile , search pattern 
differs and also same thing also differs by the settings in Application 
configuration file , Policy configuration file , Machine Config file .   In 
certain cases :   a. If code Base attribute is available , then it only 
seraches at that location . 2. In some caess it doesn't searches in GAC .   // 
Just consider the code below where i am doing the same implementation as yours 
with a hardcoded path where dll is available and my thing works , so you need 
to get into nitty gritty of same , available at above mentioned link to get the 
exact thing :    
public object ComponentInstance(string strComponentName, string strclassName) 
{ 
try 
{ 
string path = @"C:\Documents and Settings\mkamboj.ST-IDC\My Documents\Visual 
Studio Projects\TestApp\bin\Debug" ; 
StringBuilder sbTypeName = new StringBuilder("") ; 
sbTypeName.Append(strComponentName) ; 
sbTypeName.Append(".") ; 
sbTypeName.Append(strclassName) ; 
string sTypeName = sbTypeName.ToString() ; 
// Load the Assembly and get it's Type . 
Assembly objAssembly = Assembly.LoadFile(path + @"\" + strComponentName + 
".dll") ; 
// Assembly objAssembly = Assembly.Load(strComponentName + ".dll") ; 
Type objType = objAssembly.GetType(sTypeName) ; 
object objReturn = System.Activator.CreateInstance(objType) ; 
return objReturn ; 
} 
catch(Exception ex) 
{ 
throw new Exception(String.Format("Component Error", ex.Message)) ; 
} 
 
} 
try this kind of stuff  meanwhile if i get something more relevant i will get 
back to you . 
thanks , 
Mrinal

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to