According to the second reference, the Activator.CreateIntance is same as the "new" keyword.
To load the assembly from GAC:
System.Reflection.AssemblyName asmName = new System.Reflection.AssemblyName(name);
System.Reflection.Assembly asm = System.Reflection.Assembly.Load(asmName);
object obj = asm.CreateInstance(typeName);
References:
(1)
http://blogs.msdn.com/haibo_luo/archive/2005/11/17/494009.aspx
(2)
Q&A of Activator.CreateInstance
http://bytes.com/groups/net-c/586685-activator-createinstance-question
(3)
http://mironabramson.com/blog/post/2008/08/Fast-version-of-the-ActivatorCreateInstance-method-using-IL.aspx
(4)
http://blog.lozanotek.com/archive/2006/03/22/8311.aspx
Thursday, January 22, 2009
Tuesday, January 20, 2009
How to upload file using WebClient
To use System.Net.WebClient class, first, you have to create an ASPX page in the website as shown in MSDN website. Then, execute the following:
System.Net.WebClient cli = new System.Net.WebClient();
cli.UploadFile(url,
"POST",
file_name);
Reference:
http://msdn.microsoft.com/en-us/library/system.net.webclient.uploadfile(VS.71).aspx
http://www.developerfusion.com/forum/thread/38843/
http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=115
System.Net.WebClient cli = new System.Net.WebClient();
cli.UploadFile(url,
"POST",
file_name);
Reference:
http://msdn.microsoft.com/en-us/library/system.net.webclient.uploadfile(VS.71).aspx
http://www.developerfusion.com/forum/thread/38843/
http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=115
Wednesday, January 14, 2009
Handling Exception
Performance testing on catching Exception
http://www.yoda.arachsys.com/csharp/exceptions.html
When to throw exception?
http://blogs.msdn.com/kcwalina/archive/2005/03/16/396787.aspx
http://www.yoda.arachsys.com/csharp/exceptions.html
When to throw exception?
http://blogs.msdn.com/kcwalina/archive/2005/03/16/396787.aspx
Singleton
Check out the discussion of singleton here:
http://www.yoda.arachsys.com/csharp/singleton.html
Sample code extracted from the above URL :
public sealed class Singleton
{
static Singleton instance=null;
static readonly object lock_obj = new object();
Singleton()
{
}
public static Singleton Instance
{
get
{
if (instance==null)
{
lock (lock_obj)
{
if (instance==null)
{
instance = new Singleton();
}
}
}
return instance;
}
}
}
http://www.yoda.arachsys.com/csharp/singleton.html
Sample code extracted from the above URL :
public sealed class Singleton
{
static Singleton instance=null;
static readonly object lock_obj = new object();
Singleton()
{
}
public static Singleton Instance
{
get
{
if (instance==null)
{
lock (lock_obj)
{
if (instance==null)
{
instance = new Singleton();
}
}
}
return instance;
}
}
}
Subscribe to:
Posts (Atom)