ok. here is my code for singleton object, i will write down only the
necessary things..
private static Hashtable assTable;
public class EConfig {
private EConfig() {
LoadSites();
}
public static EConfig Create(){
if (source == null){
source = new EConfig();
return source;
}else{
return source;
}
}
public void LoadSites(){
string assemblyfile = @"c:\Inetpub\wwwroot\MyWeb\MyDll.dll";
FileStream fs = new FileStream(assemblyfile
,FileMode.Open,FileAccess.Read);
BinaryReader bred = new BinaryReader(fs);
Byte[] data;
try{
data = bred.ReadBytes(Convert.ToInt32((fs.Length)));
Assembly a = Assembly.Load(data);
Type[] mTypes = a.GetTypes();
foreach (Type t in mTypes){
if (t.Name == "ProjectWebLib"){
foreach (MethodInfo mi in t.GetMethods()){
assTable.Add(mi.Name,mi);
}
}
}
fs.Close();
}catch(Exception ex){
fs.Close();
}
}
public object GetMethod(string methoName){
return assTable[methoName];
}
}
now with this code i can from my page for eg.
private void Page_Load(object sender, System.EventArgs e) {
if (!IsPostBack){
// DO SOMETHING
}
// SOMETHING ELSE
MethodInfo retmethod =
(MethotInfo)EConfig.Create().GetMethod("function1" );
object res = retmethod.Invoke(null,new object[]{"hello"})
... and so on..
}
the problem with this is that even i put a breakpoint for example at
line 1 of IsPostBack the debugger never goes in!!!!
on the other hand if i want to call method "function1" without using the
singleton , and read every time the dll with the same code like the one
of the singleton it works great.
What i am trying to tell you is that when tha hashtable is filled with
methods i cannot debug at all. My singleton works great with all the
other stuff i am using ConnectionString and so on..
Thanks for help.
*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!