मैं ऐपडोमेन और एक्टिवेटर के बीच के अंतर को समझने के लिए एक प्रश्न पूछना चाहता हूं, मैंने एपडोमेन के माध्यम से अपना डीएल लोड किया। क्रिएट इंस्टेंस। लेकिन मुझे एहसास हुआ कि उदाहरण बनाने के लिए और अधिक विधि। इसलिए मैं इस विधि को कब या कहां चुनूं? example1:AppDomain.CreateInstance और Activator.CreateInstance के बीच क्या अंतर है?
// Use the file name to load the assembly into the current
// application domain.
Assembly a = Assembly.Load("example");
// Get the type to use.
Type myType = a.GetType("Example");
// Get the method to call.
MethodInfo myMethod = myType.GetMethod("MethodA");
// Create an instance.
object obj = Activator.CreateInstance(myType);
// Execute the method.
myMethod.Invoke(obj, null);
Example2:
public WsdlClassParser CreateWsdlClassParser()
{
this.CreateAppDomain(null);
string AssemblyPath = Assembly.GetExecutingAssembly().Location;
WsdlClassParser parser = null;
try
{
parser = (WsdlClassParser) this.LocalAppDomain.CreateInstanceFrom(AssemblyPath,
typeof(Westwind.WebServices.WsdlClassParser).FullName).Unwrap() ;
}
catch (Exception ex)
{
this.ErrorMessage = ex.Message;
}
return parser;
}
Example3:
private static void InstantiateMyTypeSucceed(AppDomain domain)
{
try
{
string asmname = Assembly.GetCallingAssembly().FullName;
domain.CreateInstance(asmname, "MyType");
}
catch (Exception e)
{
Console.WriteLine();
Console.WriteLine(e.Message);
}
}
आप व्याख्या कर सकते हैं कारण है कि मैं और अधिक तरीकों की आवश्यकता है या मतभेद क्या हैं?